Skip to content

Commit

Permalink
Merge pull request #89 from MisterZig/main
Browse files Browse the repository at this point in the history
Update power-profiles
  • Loading branch information
killajoe authored Nov 12, 2023
2 parents ca8cbab + 2bcbbe0 commit 44d2c25
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions etc/skel/.config/i3/scripts/power-profiles
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,32 @@ if ! command_exists systemctl ; then
exit 1
fi

# menu defined as an associative array
typeset -A menu
# default_menu_options defined as an associative array
typeset -A default_menu_options

# Menu with keys/commands
# The default options with keys/commands

menu=(
default_menu_options=(
[ Performance]="powerprofilesctl set performance"
[ Balanced]="powerprofilesctl set balanced"
[ Power Saver]="powerprofilesctl set power-saver"
[ Cancel]=""
)

# The menu that will be displayed
typeset -A menu
menu=()

# Only add power profiles that are available to menu
for key in "${!default_menu_options[@]}"; do
grep_arg=${default_menu_options[${key}]##* }
if powerprofilesctl list | grep -q "$grep_arg"; then
menu[${key}]=${default_menu_options[${key}]}
fi
done
unset grep_arg
unset default_menu_options

menu_nrows=${#menu[@]}

# Menu entries that may trigger a confirmation message
Expand Down

0 comments on commit 44d2c25

Please sign in to comment.