diff --git a/raspi-config b/raspi-config index 5ebb96e..9e26cc1 100755 --- a/raspi-config +++ b/raspi-config @@ -220,6 +220,43 @@ set_overclock() { set_config_var core_freq $3 /boot/config.txt && set_config_var sdram_freq $4 /boot/config.txt && set_config_var over_voltage $5 /boot/config.txt && + # now set up an init.d script +cat <<\EOF > /etc/init.d/switch_cpu_governor && +#!/bin/sh +### BEGIN INIT INFO +# Provides: switch_cpu_governor +# Required-Start: udev mountkernfs $remote_fs +# Required-Stop: +# Default-Start: S +# 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" + timeout 1 thd --dump /dev/input/event* | grep -q "LEFTSHIFT\|RIGHTSHIFT" + if [ $? -eq 0 ]; then + printf " Yes. Not switching scaling governor" + log_end_msg 0 + else + SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + [ -e $SYS_CPUFREQ_GOVERNOR ] && echo "ondemand" > $SYS_CPUFREQ_GOVERNOR + printf " No. Switching to ondemand scaling governor" + log_end_msg 0 + fi + ;; + *) + echo "Usage: $0 start" >&2 + exit 3 + ;; +esac +EOF + chmod +x /etc/init.d/switch_cpu_governor && + update-rc.d switch_cpu_governor defaults && whiptail --msgbox "Set overclock to preset '$1'" 20 60 2 }