From a0eed7adfafbe31997c614234fd3e0e50210f708 Mon Sep 17 00:00:00 2001 From: Daniil Tsivinsky Date: Tue, 19 Oct 2021 22:14:46 +0300 Subject: [PATCH] Add notify-on-volume script for dunst volume notifications --- bin/notify-on-volume | 17 +++++++++++++++++ dunst/dunstrc | 4 ++++ sway/config | 4 ++-- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100755 bin/notify-on-volume diff --git a/bin/notify-on-volume b/bin/notify-on-volume new file mode 100755 index 0000000..8c7bb5c --- /dev/null +++ b/bin/notify-on-volume @@ -0,0 +1,17 @@ +#! /bin/bash + +msgId="991049" + +volume=$(pamixer --get-volume) +mute=$(pamixer --get-mute) + +if [[ $volume == 0 || "$mute" == "true" ]]; then + # Show the sound muted notification + dunstify -a "notify-on-volume" -u low -i audio-volume-muted -r "$msgId" "Volume muted" +else + # Show the volume notification + dunstify -a "notify-on-volume" -u low -i audio-volume-high -r "$msgId" \ + -h int:value:"$volume" "Volume: ${volume}%" +fi + +canberra-gtk-play -i audio-volume-change -d "notify-on-volume" diff --git a/dunst/dunstrc b/dunst/dunstrc index 8a0212d..edd6947 100644 --- a/dunst/dunstrc +++ b/dunst/dunstrc @@ -54,3 +54,7 @@ timeout = 0 background = "#191e2a" foreground = "#cbccc6" frame_color = "#ff3333" + +[volume] +appname = "notify-on-volume" +history_ignore=yes diff --git a/sway/config b/sway/config index d93269a..552e4f3 100644 --- a/sway/config +++ b/sway/config @@ -99,8 +99,8 @@ exec_always --no-startup-id $HOME/dotfiles/bin/set-video-wallpaper # # Bind media keys on a keyboard to control volume and playback -bindsym XF86AudioRaiseVolume exec --no-startup-id pamixer -i 2 -bindsym XF86AudioLowerVolume exec --no-startup-id pamixer -d 2 +bindsym XF86AudioRaiseVolume exec --no-startup-id pamixer -i 2 && notify-on-volume +bindsym XF86AudioLowerVolume exec --no-startup-id pamixer -d 2 && notify-on-volume bindsym XF86AudioMute exec --no-startup-id pamixer -t bindsym XF86AudioPlay exec playerctl play-pause bindsym XF86AudioNext exec playerctl next