Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #!/bin/sh -e
  2.  
  3. # Executed by udev upon power supply status changes using this rule:
  4. # SUBSYSTEM=="power_supply", RUN+="/usr/local/bin/powerchange"
  5.  
  6. # This script sets minimum performance on battery. Adjust to suit.
  7. BATTERY_BRIGHTNESS=250
  8. # AC brightness is the maximum level.
  9.  
  10. if [ $POWER_SUPPLY_ONLINE = 1 ]; then
  11. echo "Power supply online" | systemd-cat -t powerchange
  12. x86_energy_perf_policy performance
  13. for cpufreq in /sys/devices/system/cpu/cpu*/cpufreq ; do
  14. cat $cpufreq/cpuinfo_max_freq > $cpufreq/scaling_max_freq
  15. done
  16. echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo
  17. echo 100 > /sys/devices/system/cpu/intel_pstate/max_perf_pct
  18. # Change the brightness last. If it doesn't change, we know something above failed and can check the journal.
  19. cat /sys/class/backlight/gmux_backlight/max_brightness > /sys/class/backlight/gmux_backlight/brightness
  20. else
  21. echo "Power supply offline" | systemd-cat -t powerchange
  22. x86_energy_perf_policy powersave
  23. for cpufreq in /sys/devices/system/cpu/cpu*/cpufreq ; do
  24. cat $cpufreq/scaling_min_freq > $cpufreq/scaling_max_freq
  25. done
  26. echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
  27. cat /sys/devices/system/cpu/intel_pstate/min_perf_pct > /sys/devices/system/cpu/intel_pstate/max_perf_pct
  28. # Change the brightness last. If it doesn't change, we know something above failed and can check the journal.
  29. echo $BATTERY_BRIGHTNESS > /sys/class/backlight/gmux_backlight/brightness
  30. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement