aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Kelly <kellya@arachnitech.com>2024-05-09 10:57:18 -0400
committerMatěj Cepl <mcepl@cepl.eu>2024-05-22 14:19:15 +0200
commitdeb6ce33c8828425ca1081742773d7235fdba206 (patch)
tree954baf5085d137dd04dd4420aef3a9cc971ed421
parent944aab752e2fc710184820aeee5d174b86c5233f (diff)
downloadrofi-sound-devel.tar.gz
added notification abstraction (thanks Matěj Cepl)HEADdevel
-rwxr-xr-xrofi-sound-output-chooser14
1 files 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"