parent
327302a60f
commit
54b0f16f20
@ -1,8 +1,46 @@ |
||||
#!/bin/sh |
||||
|
||||
GOVERNOR='powersave' |
||||
if [ "$1" ]; then |
||||
GOVERNOR="$1" |
||||
fi |
||||
GOVERNOR="powersave" |
||||
apply_lm=true |
||||
|
||||
while getopts 'hopPg:' opt; do |
||||
case opt in |
||||
'h') |
||||
echo "Usage: powersave [-hopP] [-g governor]" |
||||
echo " -h this message" |
||||
echo " -o set governor to ondemand and activate laptop mode" |
||||
echo " -p set governor to powersave and activate laptop mode (default)" |
||||
echo " -P set governor to performance" |
||||
echo " -g governor set governor to the specified value" |
||||
exit 0 |
||||
;; |
||||
'o') |
||||
GOVERNOR=ondemand |
||||
apply_lm=true |
||||
;; |
||||
'p') |
||||
GOVERNOR=powersave |
||||
apply_lm=true |
||||
;; |
||||
'P') |
||||
GOVERNOR=performance |
||||
apply_lm=false |
||||
;; |
||||
'g') |
||||
GOVERNOR=$OPTARG |
||||
apply_lm=false |
||||
;; |
||||
esac |
||||
'' |
||||
done |
||||
shift $((OPTIND-1)) |
||||
|
||||
echo "$GOVERNOR" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor |
||||
echo "$GOVERNOR" > /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor |
||||
|
||||
if $apply_lm; then |
||||
# "5 is a sensible time" https://www.kernel.org/doc/Documentation/laptops/laptop-mode.txt |
||||
sysctl 'vm.laptop_mode=5' |
||||
else |
||||
# disable laptop_mode |
||||
sysctl 'vm.laptop_mode=0' |
||||
fi |
||||
|
Loading…
Reference in new issue