powersave
Powersave tries to control most of the power management aspects in your machine, ACPI events, driver power management, suspend, standby, etc. I think it’s very useful since I’ve always been using apps to just control the CPU frequency so my laptop was always running out of battery in Linux sooner than in Windoz (I still think it happens also with powersave but even so I think it’s worth it to try).
Powersave works as a daemon based on a configuration which is split in schemes, each one specifies the behavior based mainly on the machine’s power source this is determined in a file called common which also defines some ways to notify warnings to the user and some other general configuration. These schemes are no more than a file with lots of variables, like what policy to apply to CPU (if it allows frequency scaling), disk acoustic level, cooling policies, display brightness, etc.
As Powersave tries to integrate several daemons like cpufreqd, acpid, etc it also allows to personalize the answer to ACPI events, as my laptop has almost any hotkey like an event I made a little script which is called when one of them is triggered. Let’s named it my_acpi_events, it has to be placed under /usr/libexec/powersave/scripts and called from configuration file events:
EVENT_OTHER="my_acpi_events"
So, in fact, any unknown event powersave gets is passed to the script and an action can be defined to deal with it. 4 parameters are passed to the script when it is called they can be identified as event ID, ACPI ID (my case ATKD), hotkey ID and serial, almost everything can be based on the hotkey ID cause it’s the ID of the pressed key. Some examples:
# We get all the parameters
EVENT=$1 # "hotkey"
ACPI=$2 # "ATKD"
WHAT=$3
SERIAL=$4
if [ "$EVENT" = "hotkey" ]; then
case $WHAT in
00000030)
HOTKEY="Vol-UP"
ACTION="volume-up"
if [ -x `which amixer` ]; then amixer -q sset Front 5+; fi
;;
00000031)
HOTKEY="Vol-DOWN"
ACTION="volume-down"
if [ -x `which amixer` ]; then amixer -q sset Front 5-; fi
;;
0000007c)
HOTKEY="Mic On/Off"
case $SERIAL in
*[1,3,5,7,9,b,d,f])
ACTION="Mic Off"
amixer -q cset numid=14 off
;;
*[0,2,4,6,8,a,c,e])
ACTION="Mic On"
amixer -q cset numid=14 on
;;
*)
echo "Serial not defined"
;;
esac
;;
...
esac
fi
These are just some simple examples about the multimedia hotkeys on my laptop but very useful when a desktop is not used. The events can be watched on /proc/acpi/event a simple cat will show the events as they are being generated (but be sure no process is blocking it cause you’ll get a “Device or resource busy”).
So I think that’s everything for a little introduction, hope this tool will improve as future versions come out keep in mind it is just the 0.14.0 version…we’ll see.