From a188201f82e6356142b00ff3b93282c6519ae8ac Mon Sep 17 00:00:00 2001 From: Quad Date: Sat, 22 May 2021 19:17:13 +0200 Subject: [PATCH] Add TDP presets to GUI --- scripts/tdp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/tdp b/scripts/tdp index 62231dd..2709f17 100755 --- a/scripts/tdp +++ b/scripts/tdp @@ -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")