Notify sound change on actual changes

pactl subscribe get spammed a lot. I think we have to check for value
difference before notifying
This commit is contained in:
Stacy Harper
2022-10-31 11:46:45 +01:00
parent 0837bb2c7e
commit 405cb53fb6

View File

@@ -6,15 +6,35 @@
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
notify_volume_change() {
vol="$(sxmo_audio.sh vol get)"
if [ "$vol" != "$lastvol" ]; then
sxmo_hook_statusbar.sh volume
sxmo_audio.sh notify
fi
lastvol="$vol"
}
notify_mic_volume_change() {
micvol="$(sxmo_audio.sh mic volget)"
if [ "$micvol" != "$lastmicvol" ]; then
sxmo_hook_statusbar.sh volume
sxmo_audio.sh micnotify
fi
lastmicvol="$micvol"
}
pactl subscribe | while read -r line; do
case "$line" in
"Event 'change' on sink "*)
sxmo_hook_statusbar.sh volume
sxmo_audio.sh notify
notify_volume_change
;;
"Event 'change' on source "*)
sxmo_hook_statusbar.sh volume
sxmo_audio.sh micnotify
notify_mic_volume_change
;;
esac
done