shell script to undervolt AMD Ryzen laptops
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
amd_laptop_undervolt/powersave.sh

52 lines
1.0 KiB

#!/bin/sh
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))
# set governor
CPUS="$(nproc)"
for c in $(seq 0 $((CPUS-1)))
do
echo $GOVERNOR > /sys/devices/system/cpu/"cpu$c"/cpufreq/scaling_governor
done
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