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