More than 4 years since the question was asked, but still my very specific solution can be useful. I never was able to find any quick fix for this.
I had the exact same problem. Years ago I solved it using a script to move the mouse once sound was detected. That stopped working since the tool I used (xdtool) would not work anymore with gnome terminals running wayland. There is a lot of information out there regarding this (for example, here), and if you can run around this issue, it is the best solution IMO.
My current solution is to run a simple script (code bellow). The solution is divided in three parts:
- Detect sound. Got the solution here;
- Alter screen/power settings. Got the solution here;
- If needed, fine tune step above regarding file permissions. Got the solution here.
If the script bellow does not work with steps 1 and 2 only, then you probably need step 3.
Steps 1 and 2 are reproduced (with a few more similar settings) in the following script:
while [ 0 ]; do
cat /proc/asound/card0/pcm3p/sub0/status | grep -qi running && (echo "Sound playing..."; gsettings set org.gnome.settings-daemon.plugins.power idle-dim false; gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'; gsettings set org.gnome.desktop.screensaver lock-delay 10000;gsettings set org.gnome.desktop.session idle-delay 0 )
sleep 55
cat /proc/asound/card0/pcm3p/sub0/status | grep -qi closed && (echo "Silence..."; gsettings reset org.gnome.settings-daemon.plugins.power idle-dim; gsettings reset org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type; gsettings set org.gnome.desktop.screensaver lock-delay 180; gsettings set org.gnome.desktop.session idle-delay 120)
done
You can execute it from any terminal. The idea is to change power saving and screen settings if music is being played, and alter it back to normal otherwise. There are a arbitrary values being set that can be changed. Details can be found in the links provided. Hope it works for anyone else but me!