cpupower icon indicating copy to clipboard operation
cpupower copied to clipboard

Add additional script to execute during power profile change?

Open eggbean opened this issue 3 years ago • 1 comments

Is there a way I can add additional actions to add to specific power profiles?

I want to disable the SD card reader (which uses around 5W even at idle) on my laptop when switching to Energy Saver, with this:

echo "2-3" | sudo tee /sys/bus/usb/drivers/usb/unbind >/dev/null

As this needs sudo, would it be possible when the extension is installed for all users?

eggbean avatar Dec 13 '20 03:12 eggbean

You will need your own policykit rule for your custom script regardless of the Installation directory of the extension. Installing an application system-wide does not grant it root permissions automatically.

This extension acchieves running cpufreqctl with a polkit rule.

Regarding other actions during profile changes (automatic or manual), we have #122 and #14 which go into a similar direction. Maybe your approach would be the easiest one to go for now. We could then add several default scripts which would add brightness handling, window manager effect handling, etc.

However, I am unsure how additional scripts should be handled with regard to polkit rules. The current (single!) polkit rule produces enough pain during the several installation processes already. I imagine that this can get really fragile and we have to be super careful to not create security issues here...

Any ideas to handle this better?

fin-ger avatar Dec 13 '20 08:12 fin-ger