User Tools

Site Tools


notes:laptop_power_management

This is an old revision of the document!


Laptop Power Management

Notes

  • This expects a laptop with a battery
  • Do not use this for desktops

Testing

  • The following commands can be ran to see if they work on specific hardware
watch -n 0.1 grep \'cpu MHz\' '/proc/cpuinfo'
sudo x86_energy_perf_policy --all 'performance' --turbo-enable '1' --force
sudo x86_energy_perf_policy --all 'power' --turbo-enable '0' --force

Dependencies

Fedora Workstation

  • kernel-tools provides x86_energy_perf_policy
sudo dnf install 'kernel-tools'

Ubuntu

  • linux-tools-common provides x86_energy_perf_policy, and linux-tools-generic provides the module for it to actually work
linux-tools-common linux-tools-generic

Scripts

AC

  • Change the backlight sysfs as-needed (see backlight notes) or remove altogether
sudo mkdir -p '/etc/udev/scripts.d' && sudo -e '/etc/udev/scripts.d/ac-power.sh' && sudo chmod +x '/etc/udev/scripts.d/ac-power.sh'
#!/usr/bin/bash
# AC
echo "$(cat '/sys/class/backlight/'*'/max_brightness')" | tee '/sys/class/backlight/'*'/brightness' > '/dev/null'
x86_energy_perf_policy --all 'performance' --turbo-enable '1' --force
# End

Battery

  • Change the backlight sysfs as-needed (see Backlight notes) or remove altogether
sudo mkdir -p '/etc/udev/scripts.d' && sudo -e '/etc/udev/scripts.d/battery-power.sh' && sudo chmod +x '/etc/udev/scripts.d/battery-power.sh'
#!/usr/bin/bash
# Battery
echo '60600' | tee '/sys/class/backlight/'*'/brightness' > '/dev/null'
x86_energy_perf_policy --all 'power' --turbo-enable '0' --force
# End

udev Rule

  • Requires the above AC and Battery scripts
sudo -e '/etc/udev/rules.d/99-power.rules' && sudo udevadm control --reload
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/etc/udev/scripts.d/ac-power.sh"
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/etc/udev/scripts.d/battery-power.sh"
/var/www/wiki/data/attic/notes/laptop_power_management.1575170843.txt.gz · Last modified: 2019/11/30 22:27 by Sean Rhone