If you have a laptop and want to get more battery life, you may already know about a handy tool from Intel called PowerTOP.
PowerTOP not only monitors your system for interrupts but has a tunable section where you can enable various power saving tweaks. Toggling one such tweak in the PowerTOP interface will show you the specific Linux system command it ran in order to enable or disable it.
Furthermore, it takes an argument ––auto-tune which lets you enable all of the power saving measures it has detected.
The package on Fedora comes with a systemd service, so enabling power saving on boot is simple, just enable the service:
sudo systemctl enable powertop
I noticed, however, that putting some devices into low-power mode on my laptop has unwanted side effects. In my case, the audio system outputs white noise and the USB mouse and keyboard are too slow to wake up (which I find annoying when I want to quickly click on, or type something).
So I took note of the Linux commands that PowerTOP was running for the USB peripherals and the audio device when it disabled power saving. The plan is to use the power of powertop ––auto-tune but I’ll then turn power saving back off for those specific devices.
I created an executable script under /usr/local/sbin/powertop-fixups.sh to disable power saving on those devices:
# Don't do powersave on intel sound, we get static noise
echo '0' > '/sys/module/snd_hda_intel/parameters/power_save'
# Don't suspend USB keyboard and mouse
# This takes time to wake up which is annoying
echo 'on' > '/sys/bus/usb/devices/1-2.1.1/power/control'
echo 'on' > '/sys/bus/usb/devices/1-2.2/power/control'
Now, I just needed to tell systemd to start my script on boot, which should require and start after the powertop service.
I created the following service file at /etc/systemd/system/powertop-fixups.service:
Then all I had to do was activate and enable it! Note that I don’t need to enable powertop.service itself, systemd will take care of that for me.
sudo systemctl daemon-reload
sudo systemctl enable powertop-fixups
Now I get the benefit of most of the power savings from PowerTOP, without the settings that were annoying.