From deb6ce33c8828425ca1081742773d7235fdba206 Mon Sep 17 00:00:00 2001 From: Alex Kelly Date: Thu, 9 May 2024 10:57:18 -0400 Subject: added notification abstraction (thanks Matěj Cepl) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rofi-sound-output-chooser | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rofi-sound-output-chooser b/rofi-sound-output-chooser index 5b67910..5fb5880 100755 --- a/rofi-sound-output-chooser +++ b/rofi-sound-output-chooser @@ -1,7 +1,17 @@ #!/usr/bin/env bash +LANG="en_US.utf8" # Outputs have spaces in them, so let's make \n the IFS IFS=$'\n' +# Make script independent on particular implementation of send client +if command -v notify-send > /dev/null 2>&1; then + SEND="notify-send" +elif command -v dunstify > /dev/null 2>&1; then + SEND="dunstify" +else + SEND="/bin/false" +fi + # An option was passed, so let's check it if [ "$@" ] then @@ -13,10 +23,10 @@ then if pactl set-default-sink "$device" then # if it worked, alert the user - dunstify -t 2000 -r 2 -u low "Activated: $desc" + $SEND -t 2000 -r 2 -u low "Activated: $desc" else # didn't work, critically alert the user - dunstify -t 2000 -r 2 -u critical "Error activating $desc" + $SEND -t 2000 -r 2 -u critical "Error activating $desc" fi else echo -en "\x00prompt\x1fSelect Output\n" -- cgit