sway_volume: add notifications via dunst

This commit is contained in:
Konstantin Koslowski 2021-02-16 08:49:15 +01:00
parent c3ec03e987
commit e7bafaf63a

View file

@ -1,6 +1,28 @@
#!/bin/bash
source $HOME/.config/sway/bin/sway_helpers
SINK=$(pactl info | grep "Default Sink" | cut -d ' ' -f 3)
ICON_PATH=$HOME/.local/share/icons/Tela-circle-dark/16/actions
NOTIFY_APP="dunstify -a \"Volume\" -r 97"
function notify() {
VOLUME=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep -oE '[0-9]*%' | head -n 1 | sed 's/%//')
MUTE=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep 'Mute:' | cut -d " " -f 2)
echo $MUTE
ICON=""
if [ "$MUTE" = "yes" ]; then
ICON=$ICON_PATH/audio-volume-muted.svg
elif [ $VOLUME -le 33 ]; then
ICON=$ICON_PATH/audio-volume-low.svg
elif [ $VOLUME -le 67 ]; then
ICON=$ICON_PATH/audio-volume-medium.svg
else
ICON=$ICON_PATH/audio-volume-high.svg
fi
$NOTIFY_APP -i $ICON -a "Volume" "$VOLUME Mute: $MUTE"
}
APP="pavucontrol"
SOUND=$HOME/.config/sway/bin/drip.ogg
@ -24,14 +46,17 @@ case $1 in
d*)
pactl set-sink-volume $SINK -5%
paplay $SOUND &
notify
;;
i*)
pactl set-sink-volume $SINK +5%
paplay $SOUND &
notify
;;
m*)
pactl set-sink-mute $SINK toggle
paplay $SOUND &
notify
;;
gui)
_check_app $APP