User Tools

Site Tools


notes:laptop_power_management

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
notes:laptop_power_management [2019/04/05 23:46] – created Sean Rhonenotes:laptop_power_management [2019/11/30 22:25] Sean Rhone
Line 1: Line 1:
 +====== 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 [[#backlight1|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'
 +
 +<code>
 +#!/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</code>
 +
 +===== Battery =====
 +
 +  * Change the ''backlight'' sysfs as-needed (see [[#backlight1|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'
 +
 +<code>
 +#!/usr/bin/bash
 +# Battery
 +echo '3750' | tee '/sys/class/backlight/'*'/brightness' > '/dev/null'
 +x86_energy_perf_policy --all 'power' --turbo-enable '0' --force
 +# End</code>
 +
 +===== udev Rule =====
 +
 +  * Requires the above AC and Battery scripts
 +
 +  sudo -e '/etc/udev/rules.d/99-power.rules' && sudo udevadm control --reload
 +
 +<code>
 +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"</code>
/var/www/wiki/data/pages/notes/laptop_power_management.txt · Last modified: 2024/05/06 22:00 by Sean Rhone