User Tools

Site Tools


linux:notes:laptop_power_udev

This is an old revision of the document!


Laptop Power Management

Testing

  • The following commands can be ran to see if they work on specific hardware
watch -n 0.5 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

sudo dnf install 'kernel-tools'

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'
#!/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'
#!/bin/bash
# Battery
echo '60600' | tee '/sys/class/backlight/'*'/brightness' > '/dev/null'
x86_energy_perf_policy --all 'balance-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"
/srv/www/wiki/data/attic/linux/notes/laptop_power_udev.1723589126.txt.gz · Last modified: by 127.0.0.1