SHARE
TWEET

/etc/init.d/switch_cpu_governor

slabua Sep 23rd, 2012 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          switch_cpu_governor
  4. # Required-Start: udev mountkernfs $remote_fs
  5. # Required-Stop:
  6. # Default-Start: S
  7. # Default-Stop:
  8. # Short-Description: Switch to ondemand cpu governor (unless shift key is pressed)
  9. # Description:
  10. ### END INIT INFO
  11.  
  12. . /lib/lsb/init-functions
  13.  
  14. case "$1" in
  15.   start)
  16.     log_daemon_msg "Checking if shift key is held down"
  17.     timeout 1 thd --dump /dev/input/event* | grep -q "LEFTSHIFT\|RIGHTSHIFT"
  18.     if [ $? -eq 0 ]; then
  19.       printf " Yes. Not switching scaling governor"
  20.       log_end_msg 0
  21.     else
  22.       SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  23.       [ -e $SYS_CPUFREQ_GOVERNOR ] && echo "ondemand" > $SYS_CPUFREQ_GOVERNOR
  24.       printf " No. Switching to ondemand scaling governor"
  25.       log_end_msg 0
  26.     fi
  27.     ;;
  28.   *)
  29.     echo "Usage: $0 start" >&2
  30.     exit 3
  31.     ;;
  32. esac
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top