mirror of
https://github.com/brain-hackers/brain-config.git
synced 2024-12-22 20:20:06 +09:00
43 lines
1.2 KiB
Bash
43 lines
1.2 KiB
Bash
#!/bin/sh
|
|
### BEGIN INIT INFO
|
|
# Provides: brain-config
|
|
# Required-Start: udev mountkernfs $remote_fs
|
|
# Required-Stop:
|
|
# Default-Start: S 2 3 4 5
|
|
# Default-Stop:
|
|
# Short-Description: Switch to ondemand cpu governor (unless shift key is pressed)
|
|
# Description:
|
|
### END INIT INFO
|
|
|
|
. /lib/lsb/init-functions
|
|
|
|
case "$1" in
|
|
start)
|
|
log_daemon_msg "Checking if shift key is held down"
|
|
if [ -x /usr/sbin/thd ] && timeout 1 thd --dump /dev/input/event* | grep -q "LEFTSHIFT\|RIGHTSHIFT"; then
|
|
printf " Yes. Not enabling ondemand scaling governor"
|
|
log_end_msg 0
|
|
else
|
|
printf " No. Switching to ondemand scaling governor"
|
|
SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
|
if [ -e $SYS_CPUFREQ_GOVERNOR ]; then
|
|
echo "ondemand" > $SYS_CPUFREQ_GOVERNOR
|
|
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
|
|
echo 100000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
|
|
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
|
|
fi
|
|
log_end_msg 0
|
|
fi
|
|
;;
|
|
stop)
|
|
;;
|
|
restart)
|
|
;;
|
|
force-reload)
|
|
;;
|
|
*)
|
|
echo "Usage: $0 start" >&2
|
|
exit 3
|
|
;;
|
|
esac
|