Add TDP presets to GUI

This commit is contained in:
Quad 2021-05-22 19:17:13 +02:00
parent 2a93b1ab66
commit a188201f82
1 changed files with 22 additions and 2 deletions

View File

@ -228,13 +228,17 @@ gui_handler() {
elif (is_help $@); then
print_help "gui"
else
# Enables graphical sudo prompt
export SUDO_ASKPASS="${script_dir}/gpd-sudo-prompt"
export gui_used=1
while : ; do
# Clear variables
gui_tdp=""
# Contains some ugly hacks to "widen" the entries for the small GPD screen, might tweak later
gui_action=$(zenity --list --title="${gui_name}" --width=400 --height=300 $gui_options --text="Chose action to perform:" --hide-column=1 --column="" --column="Action"\
gui_action=$(zenity --list --title="${gui_name}" --width=400 --height=350 $gui_options --text="Chose action to perform:" --hide-column=1 --column="" --column="Action"\
check "`printf "\n Check current TDP\n "`" \
set "`printf "\n Set new TDP (requires sudo password)\n "`" \
preset "`printf "\n Change TDP (requires sudo password)\n "`" \
set "`printf "\n Set custom TDP (requires sudo password)\n "`" \
exit "`printf "\n Exit TDP Manager\n "`")
case $gui_action in
@ -243,6 +247,21 @@ gui_handler() {
gui_msg "$($command_name check --detail)"
;;
"preset")
gui_tdp=$(
zenity --list --title "${gui_name}" --width=400 --height=350 $gui_options --text="Chose TDP to set:" --hide-column=1 --column="" --column="Wattage" \
8 "`printf "\n 8W (Ultra-low, for simple 2D games)\n "`" \
12 "`printf "\n 12W (Low power)\n "`" \
15 "`printf "\n 15W (Balanced)\n "`" \
20 "`printf "\n 20W (High power)\n "`" \
28 "`printf "\n 28W (Max power / Docked)\n "`"
)
echo $gui_tdp
if ! [ -z $gui_tdp ]; then
gui_msg "$(tdp set $gui_tdp --detail)"
fi
;;
"set")
gui_tdp=$(gui_read "Please enter TDP")
@ -265,6 +284,7 @@ gui_handler() {
}
# Command handler
# This checks which command was entered and forwards all other arguments to it
case $1 in
"check" | "c")