View Single Post
  #6   (View Single Post)  
Old 17th November 2013
albator albator is offline
Shell Scout
 
Join Date: Jul 2011
Posts: 98
Default

I wrote this script to switch from the cool mode to the High manual one. It is far from perfect but it improves things a bit.
Code:
#!/bin/ksh

# function to get the cpu load and apm current setting
set_var () {
cpu_load=$(echo "100 - $(top -1b|head -3|tail -1|awk '{print $(NF-1)'}|tr -d "%"|awk -F "." '{print $1}')"|bc)
apmd_value=`apm -P`
#echo $cpu_load
#echo $apmd_value
}

# function to adjust the apm value
cpu_adjust () {

if [ $cpu_load -gt 5 ]
then
   if [ $apmd_value = 2 ]
    then apm -H
    #then echo "switch to apm -H"
   fi
fi

if [ $cpu_load -le 5 ]
then
   if [ $apmd_value = 0 ]
    then apm -C
    #then echo "switch to apm -C"
   fi
fi
}

# Main
while true
do
set_var
cpu_adjust
sleep 1
done
Reply With Quote