I implemented a script that acts like a toggle and added it as an application shortcut to mate-panel. All it does essentially is touch or remove a file that other applications interrogate. I have processes that speak text through my speakers like saying when I get an email it reads the sender and subject line. Sometimes when I'm on the phone or something like that I want it to be silent - hence the script that touches a file. The script also changes the icon used in mate-panel.
#!/bin/bash
touchfile=/opt/clearscm/data/shh
# This just toggles the creation of the /opt/clearscm/bin/shh file
if [ -f $touchfile ]; then
rm $touchfile
cp ~/.icons/ShhOff.png ~/.icons/Shh.png
else
# Stop currently playing audio
killall play
# Stop any Google TTS
kill -9 $(cat /tmp/simple_google_tts.pid)
# Clean up tmp
rm -rf /tmp/simple_google_tts.*
# Touch shh file
touch $touchfile
# Change the icon
cp ~/.icons/ShhOn.png ~/.icons/Shh.png
fi
Under gnome-panel the change of the icon file would be sensed and re-drawn in the panel. It was a good way for me to know if the sound was on or off.
mate-panel doesn't do this. I was hoping that perhaps I could send mate-panel a signal to refresh the icons.