Update system-menu stuff

This commit is contained in:
Alexander Rosenberg 2023-11-27 18:26:14 -08:00
parent 21acf774a5
commit 45995c6924
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
2 changed files with 16 additions and 14 deletions

View File

@ -1,20 +1,22 @@
#!/usr/bin/env zsh
# Format: label action condition
local entries=('Select system sound output' 'select-sound-output.sh' 'true'
'Configure USB device access' 'usbguard-menu.py' 'pgrep usbguard-daemon'
'Power settings (restart and shutdown)' 'system-power-menu.sh' 'true')
local fuzzel_input=""
declare -A entry_map
for ((i = 1; i <= ${#entries}; i+=3)); do
if eval "${entries[${i} + 2]}" >/dev/null 2>&1; then
entry_map["${entries[${i}]}"]="${entries[${i} + 1]}"
fuzzel_input+="${entries[${i}]}\n"
fi
done
local scripts_dir="$(dirname "$(realpath "${0}")")"
choice="$(fuzzel --index -d <<'EOF'
Select system sound output
Power settings (restart and shutdown)
EOF
)"
choice="$(echo -n "${fuzzel_input}" | fuzzel -d)"
(( ${?} != 0 )) && exit
echo $choice
case "${choice}" in
0)
"${scripts_dir}/select-sound-output.sh"
;;
1)
"${scripts_dir}/system-power-menu.sh"
;;
esac
eval "${scripts_dir}/${entry_map["${choice}"]}"