diff options
| author | Robert Günzler <r@gnzler.io> | 2021-02-23 13:29:45 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2021-04-26 02:09:45 +0200 |
| commit | 3085bc77b3f1fcc31259997a30be306a4d80f6bc (patch) | |
| tree | c0ee9e33f0ea1be49d1b89806d5c199d8b308c5b /bin/soundswitch | |
| parent | e44c7474fe06bcc7bd5f9a9fea90b3917a4b1573 (diff) | |
bin/menu: pass bemenu options globally through env var
Diffstat (limited to 'bin/soundswitch')
| -rwxr-xr-x | bin/soundswitch | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/bin/soundswitch b/bin/soundswitch index 3f893c6..acd287a 100755 --- a/bin/soundswitch +++ b/bin/soundswitch @@ -15,12 +15,14 @@ for tool in jq swq pactl perl; do fi done - - DEFAULT_PROFILE="output:analog-stereo+input:analog-stereo" HDMI_PROFILE="output:hdmi-stereo" export MENU_PROMPT="soundswitch" +_menu() { + menu -l 8 +} + mode= output= input= @@ -67,29 +69,37 @@ done shift $((OPTIND-1)) # ask mode +_mode_global=" global" +_mode_focused=" focused" +_mode_profile_card=" card profile" +_mode_profile_hdmi=" hdmi profile" +_mode_profile_reset=" reset profile" if [ -z "$mode" ]; then - printf "global\nfocused\ncard profile\nhdmi profile\nreset profile\n" | menu | { + printf "$_mode_global\n$_mode_focused\n$_mode_profile_card\n$_mode_profile_hdmi\n$_mode_profile_reset\n" | _menu | { read -r line case ${line} in - global) exec "$0" -g "$*" ;; - focused) exec "$0" -f "$*" ;; - "card profile") exec "$0" -p "$*" ;; - "hdmi profile") exec "$0" -H "$*" ;; - "reset profile") exec "$0" -R "$*" ;; - *) usage ;; + $_mode_global) exec "$0" -g "$*" ;; + $_mode_focused) exec "$0" -f "$*" ;; + $_mode_profile_card) exec "$0" -p "$*" ;; + $_mode_profile_hdmi) exec "$0" -H "$*" ;; + $_mode_profile_reset) exec "$0" -R "$*" ;; + *) + usage ;; esac } exit $? fi +_mode_output=" output" +_mode_input=" input" if [ -n "$mode" ]; then # ask target? if [ -z "$output" ] && [ -z "$input" ]; then - printf "output\ninput\n" | menu | { + printf "$_mode_output\n$_mode_input\n" | _menu | { read -r line case ${line} in - output) exec "$0" -O $_args ;; - input) exec "$0" -I $_args ;; + $_mode_output) exec "$0" -O $_args ;; + $_mode_input) exec "$0" -I $_args ;; *) usage ;; esac } @@ -177,7 +187,7 @@ profile) | cut -d'~' -f2- \ | tr '\r' '\n' \ | xargs -L1 \ - | menu \ + | _menu \ | perl -pe 's/^\s*([^\s]+):\s.*$/\1/') if [ -z "${target_profile}" ]; then exit 1 |