From 45995c69243d0dc07010d4eaa64ac1f51b60513c Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Mon, 27 Nov 2023 18:26:14 -0800 Subject: [PATCH] Update system-menu stuff --- system-menu/system-menu.sh | 30 ++++++++++--------- .../usbguard-menu.py | 0 2 files changed, 16 insertions(+), 14 deletions(-) rename usbguard-menu.py => system-menu/usbguard-menu.py (100%) diff --git a/system-menu/system-menu.sh b/system-menu/system-menu.sh index 3449cc1..e6dd235 100755 --- a/system-menu/system-menu.sh +++ b/system-menu/system-menu.sh @@ -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}"]}" diff --git a/usbguard-menu.py b/system-menu/usbguard-menu.py similarity index 100% rename from usbguard-menu.py rename to system-menu/usbguard-menu.py