From a502b722992c9286e17f3ad8cb1c071b5d91a55f Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Mon, 30 Oct 2023 23:27:58 -0700 Subject: [PATCH] Upgrade system menu features --- .../select-sound-output.sh | 4 ++-- system-menu/system-menu.sh | 20 +++++++++++++++++++ system-menu/system-power-menu.sh | 17 ++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) rename select-sound-output.sh => system-menu/select-sound-output.sh (93%) create mode 100755 system-menu/system-menu.sh create mode 100755 system-menu/system-power-menu.sh diff --git a/select-sound-output.sh b/system-menu/select-sound-output.sh similarity index 93% rename from select-sound-output.sh rename to system-menu/select-sound-output.sh index 6d3f373..4585abe 100755 --- a/select-sound-output.sh +++ b/system-menu/select-sound-output.sh @@ -22,7 +22,7 @@ if (( "${?}" != 0 )); then fi local selected_id="$(echo "${choice}" | grep -Eo '^[0-9]+')" pactl set-default-sink "${selected_id}" -local selected_name=$(echo "${choice}" \ +local selected_name="$(echo "${choice}" \ | cut -c "$(("${#selected_id}" + 3))-" \ - | grep -Po '^.+(?= \()') + | grep -Po '^.+(?= \()')" notify-send 'Output Device' "${selected_name} (${selected_id})" diff --git a/system-menu/system-menu.sh b/system-menu/system-menu.sh new file mode 100755 index 0000000..3449cc1 --- /dev/null +++ b/system-menu/system-menu.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env zsh + +local scripts_dir="$(dirname "$(realpath "${0}")")" +choice="$(fuzzel --index -d <<'EOF' +Select system sound output +Power settings (restart and shutdown) +EOF +)" + +(( ${?} != 0 )) && exit + +echo $choice +case "${choice}" in + 0) + "${scripts_dir}/select-sound-output.sh" + ;; + 1) + "${scripts_dir}/system-power-menu.sh" + ;; +esac diff --git a/system-menu/system-power-menu.sh b/system-menu/system-power-menu.sh new file mode 100755 index 0000000..6089383 --- /dev/null +++ b/system-menu/system-power-menu.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env zsh + +choice="$(fuzzel --index -d <<'EOF' +Shutdown +Restart +EOF +)" + +(( ${?} != 0 )) && exit +case "${choice}" in + 0) + poweroff + ;; + 1) + restart + ;; +esac