Add notify-on-volume script for dunst volume notifications

This commit is contained in:
2021-10-19 22:14:46 +03:00
parent eda5f226f3
commit a0eed7adfa
3 changed files with 23 additions and 2 deletions

17
bin/notify-on-volume Executable file
View File

@@ -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"

View File

@@ -54,3 +54,7 @@ timeout = 0
background = "#191e2a" background = "#191e2a"
foreground = "#cbccc6" foreground = "#cbccc6"
frame_color = "#ff3333" frame_color = "#ff3333"
[volume]
appname = "notify-on-volume"
history_ignore=yes

View File

@@ -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 # Bind media keys on a keyboard to control volume and playback
bindsym XF86AudioRaiseVolume exec --no-startup-id pamixer -i 2 bindsym XF86AudioRaiseVolume exec --no-startup-id pamixer -i 2 && notify-on-volume
bindsym XF86AudioLowerVolume exec --no-startup-id pamixer -d 2 bindsym XF86AudioLowerVolume exec --no-startup-id pamixer -d 2 && notify-on-volume
bindsym XF86AudioMute exec --no-startup-id pamixer -t bindsym XF86AudioMute exec --no-startup-id pamixer -t
bindsym XF86AudioPlay exec playerctl play-pause bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next bindsym XF86AudioNext exec playerctl next