I use an external monitor that has an audio output and use it for my audio system. However, if the desktop enters in sleep mode, it automatically switches to the laptop speakers.
I want to use pacmd list-sink-inputs | grep 'RUNNING'
to check every 20 seconds if sound is playing, and if so reset the idle time automatically.
Currently I use caffeine, but that disables idling completely.
How can I prevent the computer going to sleep when sound is playing? How can I reset the idle time from the command line?