random-scripts/system-menu/system-menu.sh

27 lines
1.0 KiB
Bash
Raw Normal View History

2023-10-30 23:27:58 -07:00
#!/usr/bin/env zsh
2023-11-27 19:26:54 -08:00
pgrep swayidle && swayidle_state="Enabled" || swayidle_state="Disabled"
2023-11-27 18:26:14 -08:00
# Format: label action condition
local entries=('Select system sound output' 'select-sound-output.sh' 'true'
2023-11-27 19:26:54 -08:00
"Enable or disable system sleep (Current: ${swayidle_state})" 'system-sleep-menu.sh' 'true'
2023-12-20 20:21:40 -08:00
'Enable or disable TV' 'tv-power-menu.sh' '[[ "${HOST}" = "alexanders-desktop" ]]'
2023-11-27 18:26:14 -08:00
'Configure USB device access' 'usbguard-menu.py' 'pgrep usbguard-daemon'
'Power settings (restart and shutdown)' 'system-power-menu.sh' 'true')
2023-11-27 19:26:54 -08:00
local entry_array=()
2023-11-27 21:24:02 -08:00
local enabled_entries=()
2023-11-27 18:26:14 -08:00
for ((i = 1; i <= ${#entries}; i+=3)); do
if eval "${entries[${i} + 2]}" >/dev/null 2>&1; then
2023-11-27 19:26:54 -08:00
entry_array[$((${i} / 3 + 1))]="${entries[${i}]}"
2023-11-27 21:24:02 -08:00
enabled_entries+=(${entries[@]:${i} - 1:3})
2023-11-27 18:26:14 -08:00
fi
done
2023-10-30 23:27:58 -07:00
local scripts_dir="$(dirname "$(realpath "${0}")")"
2023-11-27 19:26:54 -08:00
choice="$(printf '%s\n' ${entry_array} | fuzzel --index -d)"
2023-10-30 23:27:58 -07:00
(( ${?} != 0 )) && exit
2023-11-27 21:24:02 -08:00
eval "${scripts_dir}/${enabled_entries["${choice}" * 3 + 2]}"