#!/bin/bash
cpuexec=/usr/bin/cpufreq-set
usage () {
printf "usage: cpu -p | -o | -pp | -f FREQ
-p|--powersave switch to powersave
-o|--ondemand switch to ondemand
-pp|--perf switch to performance
-f|--freq manually set freq
-h|--help show this help\n"
}
check () {
sensors | grep '^temp'
cat /proc/cpuinfo | grep '^cpu\ MHz'
if [ -n "$governor" ]; then
echo "Switched to $governor governor"
elif [ -n "$freq" ]; then
echo "Switched manually to $freq MHz"
fi
}
set_governor () {
if [ -s '$governor' ]; then
usage
elif [ -f $cpuexec ]; then
sudo $cpuexec -g $governor && check
fi
}
set_freq () {
$cpuexec -f "$freq"MHz && check
}
while true ; do
case "$1" in
-p|--powersave) governor="powersave" && set_governor ; exit 1 ;;
-o|--ondemand) governor="ondemand" && set_governor ; exit 1 ;;
-pp|--performance) governor="performance" && set_governor ; exit 1 ;;
-f|--freq) freq=$2 && set_freq ; exit 1 ;;
-h|--help) usage ; exit 0 ;;
*) check ; exit 0 ;;
esac
done
cpufreq-set+sensors
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment