Eu tenho lutado com a mesma coisa. Eu encontrei alguns outros posts que falaram sobre o uso de pactl para verificar o status do pulseaudio. Aqui está um link:
Eu tentei criar um script muito simples que irá alterar o tempo limite de suspensão nas configurações de energia do Cinnamon para nunca temporariamente enquanto a música estiver tocando e, em seguida, reverter quando a música parar. Esta é a minha primeira tentativa real em um script, então se você puder melhorar, fique à vontade. Provavelmente só funcionará em Canela.
#!/bin/sh
# Script to temporarily set Cinnamon's suspend timout for AC and battery to "Never"
# while audio is playing. It then reverts the settings when audio is no longer detected.
# Create directory to store settings if it doesn't exist.
if [ ! -d ~/.config/audiocaffeine ]; then
echo "Configuration directory not found!"
echo "Creating ~/.config/audiocaffeine"
mkdir ~/.config/audiocaffeine
fi
# Restore previous value for AC suspend timeout if script
# was interrupted.
if [ -f ~/.config/audiocaffeine/acsuspend ]; then
echo "Restoring previous AC suspend timeout."
read acsuspendtime < ~/.config/audiocaffeine/acsuspend
gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout $acsuspendtime
echo "Removing temporary file ~/.config/audiocaffeine/acsuspend"
rm ~/.config/audiocaffeine/acsuspend
fi
# Restore previous value for battery suspend timeout if script
# was interrupted.
if [ -f ~/.config/audiocaffeine/battsuspend ]; then
echo "Restoring previous battery suspend timeout."
read battsuspendtime < ~/.config/audiocaffeine/battsuspend
gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout $battsuspendtime
echo "Removing temporary file ~/.config/audiocaffeine/battsuspend"
rm ~/.config/audiocaffeine/battsuspend
fi
# Start main loop to check if audio is playing
while true; do
# Use pactl to detect if there are any running audio sources.
if pactl list | grep -q RUNNING; then
echo "Audio detected."
# If AC timeout was not previously saved, then save it.
if [ ! -f ~/.config/audiocaffeine/acsuspend ]; then
echo "Saving current AC suspend timeout."
gsettings get org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout > ~/.config/audiocaffeine/acsuspend
fi
# If battery timeout was not previously saved, then save it.
if [ ! -f ~/.config/audiocaffeine/battsuspend ]; then
echo "Saving current battery suspend timeout."
gsettings get org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout > ~/.config/audiocaffeine/battsuspend
fi
# Set the suspend timouts to Never using gsettings.
echo "Changing suspend timeouts."
gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout 0
gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout 0
else
echo "No audio detected."
# Restore previous value for AC suspend timeout and delete the
# temporary file storing it.
if [ -f ~/.config/audiocaffeine/acsuspend ]; then
echo "Restoring previous AC suspend timeout."
read acsuspendtime < ~/.config/audiocaffeine/acsuspend
gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout $acsuspendtime
echo "Removing temporary file ~/.config/audiocaffeine/acsuspend"
rm ~/.config/audiocaffeine/acsuspend
fi
# Restore previous value for battery suspend timeout and delete the
# temporary file storing it.
if [ -f ~/.config/audiocaffeine/battsuspend ]; then
echo "Restoring previous battery suspend timeout."
read battsuspendtime < ~/.config/audiocaffeine/battsuspend
gsettings set org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout $battsuspendtime
echo "Removing temporary file ~/.config/audiocaffeine/battsuspend"
rm ~/.config/audiocaffeine/battsuspend
fi
fi
# Pause the script for 60 seconds before doing the loop again.
sleep 60s
done