dotfiles/dot_bin/executable_set_hwp

51 lines
814 B
Plaintext
Raw Permalink Normal View History

2023-09-29 21:18:28 -04:00
#!/bin/sh
# set the HWP preference for all cpus in sysfs
cpus="/sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference"
usage() {
script=${0##*/}
echo
echo "Invalid usage of ${script}!"
echo
echo "The following options are allowed"
echo
echo "-----------"
echo "$script -1 : default"
echo "$script 0 : power"
echo "$script 1 : balance_power"
echo "$script 2 : balance_performance"
echo "$script 3 : performance"
echo "-----------"
echo
exit 1
}
set_pref() {
for cpu in $cpus; do
echo "$1" > "$cpu"
done
}
case "$1" in
-1)
set_pref "default"
;;
0)
set_pref "power"
;;
1)
set_pref "balance_power"
;;
2)
set_pref "balance_performance"
;;
3)
set_pref "performance"
;;
*)
usage "invalid argument"
esac