~/.xmonad/scripts/volume-daemon
#!/bin/sh
set -eu
get_volume () {
amixer sget Master | tail -1 | awk -F"[][%]" '{ print $2 }'
}
is_mute () {
amixer sget Master | tail -1 | awk -F"[][]" '{ print $4 }'
}
oldvol="$(get_volume)"
oldvolState="$(is_mute)"
while true; do
newvol="$(get_volume)"
newvolState="$(is_mute)"
if [ ! "$newvol" -eq "$oldvol" ]; then
#notify-send "volume change" "volume has changed to $newvol"
volnoti-show $newvol
fi
if [ "$newvolState" != "$oldvolState" ]; then
#notify-send "volume change" "volume has changed to $newvolState"
if [ "$newvolState" = "off" ]; then
volnoti-show -m
fi
fi
oldvol="$newvol"
oldvolState="$newvolState"
sleep 1
done