Update Debian/CPU Governor/setup.sh

Added extra IF statements to determine if a machine is already on a "Performance" or "Powersave" energy plan and adjust the menu accordingly.
This commit is contained in:
b.waal 2024-09-28 17:31:34 +02:00
parent 73f0392238
commit 340deedd52

View File

@ -1,5 +1,8 @@
#!/bin/bash
#Static Var
file=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# Precheck
if [ $UID != 0 ]; then
TERM=ansi whiptail --title "Info" --infobox "Please run as root!" 7 23
@ -11,12 +14,25 @@ fi
# Check if file exists
if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]; then
# If file exists show menu
Governor=$(whiptail --title "Choose a power plan" --radiolist \
"Choose user's permissions" 9 61 3 \
"Performance" "Run the CPU at the maximum frequency" OFF \
"Ondemand" "Scales the frequency according to load" OFF \
"Powersave" "Run the CPU at the minimum frequency" ON 3>&1 1>&2 2>&3)
if grep -Fxq "powersave" $file
then
# If file exists on performance settings autoselect powersave in menu
Governor=$(whiptail --title "Choose a power plan" --radiolist \
"Choose user's permissions" 9 61 3 \
"Performance" "Run the CPU at the maximum frequency" ON \
"Ondemand" "Scales the frequency according to load" OFF \
"Powersave" "Run the CPU at the minimum frequency" OFF 3>&1 1>&2 2>&3)
elif grep -Fxq "performance" $file
then
# If file exists on performance settings autoselect powersave in menu
Governor=$(whiptail --title "Choose a power plan" --radiolist \
"Choose user's permissions" 9 61 3 \
"Performance" "Run the CPU at the maximum frequency" OFF \
"Ondemand" "Scales the frequency according to load" OFF \
"Powersave" "Run the CPU at the minimum frequency" ON 3>&1 1>&2 2>&3)
else
echo ""
fi
else
TERM=ansi whiptail --title "Info" --infobox "This CPU/OS does not support a governor!" 7 44
sleep 3