Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh -e
- # Executed by udev upon power supply status changes using this rule:
- # SUBSYSTEM=="power_supply", RUN+="/usr/local/bin/powerchange"
- # This script sets minimum performance on battery. Adjust to suit.
- BATTERY_BRIGHTNESS=250
- # AC brightness is the maximum level.
- if [ $POWER_SUPPLY_ONLINE = 1 ]; then
- echo "Power supply online" | systemd-cat -t powerchange
- x86_energy_perf_policy performance
- for cpufreq in /sys/devices/system/cpu/cpu*/cpufreq ; do
- cat $cpufreq/cpuinfo_max_freq > $cpufreq/scaling_max_freq
- done
- echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo
- echo 100 > /sys/devices/system/cpu/intel_pstate/max_perf_pct
- # Change the brightness last. If it doesn't change, we know something above failed and can check the journal.
- cat /sys/class/backlight/gmux_backlight/max_brightness > /sys/class/backlight/gmux_backlight/brightness
- else
- echo "Power supply offline" | systemd-cat -t powerchange
- x86_energy_perf_policy powersave
- for cpufreq in /sys/devices/system/cpu/cpu*/cpufreq ; do
- cat $cpufreq/scaling_min_freq > $cpufreq/scaling_max_freq
- done
- echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
- cat /sys/devices/system/cpu/intel_pstate/min_perf_pct > /sys/devices/system/cpu/intel_pstate/max_perf_pct
- # Change the brightness last. If it doesn't change, we know something above failed and can check the journal.
- echo $BATTERY_BRIGHTNESS > /sys/class/backlight/gmux_backlight/brightness
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement