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:
@@ -6,15 +6,35 @@
|
|||||||
# shellcheck source=scripts/core/sxmo_common.sh
|
# shellcheck source=scripts/core/sxmo_common.sh
|
||||||
. 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
|
pactl subscribe | while read -r line; do
|
||||||
case "$line" in
|
case "$line" in
|
||||||
"Event 'change' on sink "*)
|
"Event 'change' on sink "*)
|
||||||
sxmo_hook_statusbar.sh volume
|
notify_volume_change
|
||||||
sxmo_audio.sh notify
|
|
||||||
;;
|
;;
|
||||||
"Event 'change' on source "*)
|
"Event 'change' on source "*)
|
||||||
sxmo_hook_statusbar.sh volume
|
notify_mic_volume_change
|
||||||
sxmo_audio.sh micnotify
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
Reference in New Issue
Block a user