#!/bin/bash
# made for Ubuntu-12.04, cause i missed the old button to pull down cpu-s
# has to be run as "bash" for the numerical calculation with "let"
#
# first get the current state of the cpu-setting
gov=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`;
#echo "old $gov";
# now toggle the setting - may go wrong if future kernel may change names
# --- but why should they?
# if current cpu setting is ondemand, set new to powersave or set ondemand
if [ "$gov" = "ondemand" ]; then
gov="powersave";
else
gov="ondemand";
fi
#echo "new $gov"
# no count thru all available cpu-cores and set the new state
let cpu=0
#for i in 0 1; do
for i in /sys/devices/system/cpu/cpu?; do
#echo "$cpu - cpufreq-selector -c $i -g $gov"
cpufreq-selector -c $cpu -g $gov
let cpu=cpu+1
done
# give some visual response what was done
zenity --notification --text "cpugoverner: $gov" &