Prevent Mint from suspending while playing music in Spotify
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
In Linux Mint 17 I have Suspend when inactive for
under Power Management
set to 10 minutes.
The problem is that the system suspends even when I'm listening to music using Spotify.
Is there any way to prevent this?
linux-mint power-management
add a comment |Â
up vote
2
down vote
favorite
In Linux Mint 17 I have Suspend when inactive for
under Power Management
set to 10 minutes.
The problem is that the system suspends even when I'm listening to music using Spotify.
Is there any way to prevent this?
linux-mint power-management
This solution looks relevant, but the links in the solution are dead at time of writing.
â LondonRob
Mar 22 '16 at 19:43
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
In Linux Mint 17 I have Suspend when inactive for
under Power Management
set to 10 minutes.
The problem is that the system suspends even when I'm listening to music using Spotify.
Is there any way to prevent this?
linux-mint power-management
In Linux Mint 17 I have Suspend when inactive for
under Power Management
set to 10 minutes.
The problem is that the system suspends even when I'm listening to music using Spotify.
Is there any way to prevent this?
linux-mint power-management
linux-mint power-management
asked Oct 4 '14 at 17:25
LondonRob
14710
14710
This solution looks relevant, but the links in the solution are dead at time of writing.
â LondonRob
Mar 22 '16 at 19:43
add a comment |Â
This solution looks relevant, but the links in the solution are dead at time of writing.
â LondonRob
Mar 22 '16 at 19:43
This solution looks relevant, but the links in the solution are dead at time of writing.
â LondonRob
Mar 22 '16 at 19:43
This solution looks relevant, but the links in the solution are dead at time of writing.
â LondonRob
Mar 22 '16 at 19:43
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
I found this article which suggests a couple of ways to stop the screensaver from activating. I have not tested this but since they presumably issue events to stop the activation (the second does at least), that should also count as activity for the inactivity monitor. You'll have to test this though, I'm not sure it will work.
Install
caffeine
. This can be done by adding appa
to your system and then installing it like any other package. As long as you're using the normal Mint, this should also work for you.sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeineThen, launch
caffeine
and its icon should appear in your system tray. You can choose which programs should cancel suspending.Note: As of the 2.7 release of caffeine, the program no longer has a GUI and works only as a daemon. When running, it will prevent the screensaver from activating so long as the active window is full screen.
The LightsOn script. It won't check spotify by default but it is easy enough to modify it to do so. Just add
spotify
to thedelay_progs
array at the beginging of the script:delay_progs=("spotify")
Then, add the script to your startup programs so it runs in the background. and it should stop you from suspending if spotify is running. Note that this does not check whether any music is playing, just whether the program is running.
Let me know if these don't work for the suspension and I'll try and hack something together using xdotool
or similar programs.
I've used caffeine and it's worked alright in the past. It seems buggy though since I've had it active and the screensaver would still kick in. Haven't debugged it further, though.
â slmâ¦
Oct 5 '14 at 15:29
@slm I haven't so I can't speak as to how well it works. The second solution, the shell script, looks very interesting. It's relatively straightforward and should be easy to expand to blocking suspension.
â terdonâ¦
Oct 5 '14 at 15:33
yeah I was just giving a recounting of my experience. 2nd solution is prob. A better approach to try.
â slmâ¦
Oct 5 '14 at 15:35
The script looks pretty good. Could you add a line to your answer showing how to run the script at start-up?
â LondonRob
Oct 6 '14 at 22:25
@LondonRob that depends on your desktop environment but for most it's something along the lines of settings => startup programs. That's where you can find it on Cinnamon for example. Alternatively, copy thecaffeine.desktop
file from/usr/share/applications
to~/.config/autostart/
.
â terdonâ¦
Oct 6 '14 at 22:39
 |Â
show 1 more comment
up vote
0
down vote
I just posted an answer for a similar question:
Linux Mint: How to Avoid Suspending While Music is Playing
I have written a script to set the suspend timeout to "Never" while pactl detects a running audio source, then reverts the setting when no audio sources are detected.
Here is a copy of the latest answer and script:
I have done a little more work on the above script and it should now work in Cinnamon, Mate and Ubuntu running Gnome. I have tried it out on Live USB versions of Linux Mint 19 Cinnamon and Mate as well as Ubuntu 18.04 - Gnome.
#!/bin/sh
# Audiocaffeine
# Works in Linux Mint 19 - Cinnamon, Linux Mint 19 - Mate, Ubuntu 18.04 - Gnome
# Script to temporarily set suspend timout for AC and battery to "Never"
# while audio is playing. It then reverts the settings when audio is no longer detected.
# Determine if a valid desktop environment is running and exit if it doesn't.
echo "Reported desktop environment: ""$XDG_CURRENT_DESKTOP"
if [ "$XDG_CURRENT_DESKTOP" = "X-Cinnamon" ]; then
actimeoutid="org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout"
batttimeoutid="org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout"
disablevalue=0
elif [ "$XDG_CURRENT_DESKTOP" = "MATE" ]; then
actimeoutid="org.mate.power-manager sleep-computer-ac"
batttimeoutid="org.mate.power-manager sleep-computer-battery"
disablevalue=0
elif [ "$XDG_CURRENT_DESKTOP" = "ubuntu:GNOME" ]; then
actimeoutid="org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type"
batttimeoutid="org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type"
disablevalue="nothing"
else
echo "No valid desktop environment is running"
exit 1
fi
# Create .config directory to store settings if it doesn't exist.
if [ ! -d ~/.config ]; then
echo ".config directory not found!"
echo "Creating ~/.config"
mkdir ~/.config
fi
# Create audiocaffeine 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 $actimeoutid $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 $batttimeoutid $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 "State: 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 $actimeoutid > ~/.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 $batttimeoutid > ~/.config/audiocaffeine/battsuspend
fi
# Set the suspend timouts to Never using gsettings.
echo "Changing suspend timeouts."
gsettings set $actimeoutid $disablevalue
gsettings set $batttimeoutid $disablevalue
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 $actimeoutid $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 $batttimeoutid $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
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
I found this article which suggests a couple of ways to stop the screensaver from activating. I have not tested this but since they presumably issue events to stop the activation (the second does at least), that should also count as activity for the inactivity monitor. You'll have to test this though, I'm not sure it will work.
Install
caffeine
. This can be done by adding appa
to your system and then installing it like any other package. As long as you're using the normal Mint, this should also work for you.sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeineThen, launch
caffeine
and its icon should appear in your system tray. You can choose which programs should cancel suspending.Note: As of the 2.7 release of caffeine, the program no longer has a GUI and works only as a daemon. When running, it will prevent the screensaver from activating so long as the active window is full screen.
The LightsOn script. It won't check spotify by default but it is easy enough to modify it to do so. Just add
spotify
to thedelay_progs
array at the beginging of the script:delay_progs=("spotify")
Then, add the script to your startup programs so it runs in the background. and it should stop you from suspending if spotify is running. Note that this does not check whether any music is playing, just whether the program is running.
Let me know if these don't work for the suspension and I'll try and hack something together using xdotool
or similar programs.
I've used caffeine and it's worked alright in the past. It seems buggy though since I've had it active and the screensaver would still kick in. Haven't debugged it further, though.
â slmâ¦
Oct 5 '14 at 15:29
@slm I haven't so I can't speak as to how well it works. The second solution, the shell script, looks very interesting. It's relatively straightforward and should be easy to expand to blocking suspension.
â terdonâ¦
Oct 5 '14 at 15:33
yeah I was just giving a recounting of my experience. 2nd solution is prob. A better approach to try.
â slmâ¦
Oct 5 '14 at 15:35
The script looks pretty good. Could you add a line to your answer showing how to run the script at start-up?
â LondonRob
Oct 6 '14 at 22:25
@LondonRob that depends on your desktop environment but for most it's something along the lines of settings => startup programs. That's where you can find it on Cinnamon for example. Alternatively, copy thecaffeine.desktop
file from/usr/share/applications
to~/.config/autostart/
.
â terdonâ¦
Oct 6 '14 at 22:39
 |Â
show 1 more comment
up vote
4
down vote
accepted
I found this article which suggests a couple of ways to stop the screensaver from activating. I have not tested this but since they presumably issue events to stop the activation (the second does at least), that should also count as activity for the inactivity monitor. You'll have to test this though, I'm not sure it will work.
Install
caffeine
. This can be done by adding appa
to your system and then installing it like any other package. As long as you're using the normal Mint, this should also work for you.sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeineThen, launch
caffeine
and its icon should appear in your system tray. You can choose which programs should cancel suspending.Note: As of the 2.7 release of caffeine, the program no longer has a GUI and works only as a daemon. When running, it will prevent the screensaver from activating so long as the active window is full screen.
The LightsOn script. It won't check spotify by default but it is easy enough to modify it to do so. Just add
spotify
to thedelay_progs
array at the beginging of the script:delay_progs=("spotify")
Then, add the script to your startup programs so it runs in the background. and it should stop you from suspending if spotify is running. Note that this does not check whether any music is playing, just whether the program is running.
Let me know if these don't work for the suspension and I'll try and hack something together using xdotool
or similar programs.
I've used caffeine and it's worked alright in the past. It seems buggy though since I've had it active and the screensaver would still kick in. Haven't debugged it further, though.
â slmâ¦
Oct 5 '14 at 15:29
@slm I haven't so I can't speak as to how well it works. The second solution, the shell script, looks very interesting. It's relatively straightforward and should be easy to expand to blocking suspension.
â terdonâ¦
Oct 5 '14 at 15:33
yeah I was just giving a recounting of my experience. 2nd solution is prob. A better approach to try.
â slmâ¦
Oct 5 '14 at 15:35
The script looks pretty good. Could you add a line to your answer showing how to run the script at start-up?
â LondonRob
Oct 6 '14 at 22:25
@LondonRob that depends on your desktop environment but for most it's something along the lines of settings => startup programs. That's where you can find it on Cinnamon for example. Alternatively, copy thecaffeine.desktop
file from/usr/share/applications
to~/.config/autostart/
.
â terdonâ¦
Oct 6 '14 at 22:39
 |Â
show 1 more comment
up vote
4
down vote
accepted
up vote
4
down vote
accepted
I found this article which suggests a couple of ways to stop the screensaver from activating. I have not tested this but since they presumably issue events to stop the activation (the second does at least), that should also count as activity for the inactivity monitor. You'll have to test this though, I'm not sure it will work.
Install
caffeine
. This can be done by adding appa
to your system and then installing it like any other package. As long as you're using the normal Mint, this should also work for you.sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeineThen, launch
caffeine
and its icon should appear in your system tray. You can choose which programs should cancel suspending.Note: As of the 2.7 release of caffeine, the program no longer has a GUI and works only as a daemon. When running, it will prevent the screensaver from activating so long as the active window is full screen.
The LightsOn script. It won't check spotify by default but it is easy enough to modify it to do so. Just add
spotify
to thedelay_progs
array at the beginging of the script:delay_progs=("spotify")
Then, add the script to your startup programs so it runs in the background. and it should stop you from suspending if spotify is running. Note that this does not check whether any music is playing, just whether the program is running.
Let me know if these don't work for the suspension and I'll try and hack something together using xdotool
or similar programs.
I found this article which suggests a couple of ways to stop the screensaver from activating. I have not tested this but since they presumably issue events to stop the activation (the second does at least), that should also count as activity for the inactivity monitor. You'll have to test this though, I'm not sure it will work.
Install
caffeine
. This can be done by adding appa
to your system and then installing it like any other package. As long as you're using the normal Mint, this should also work for you.sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeineThen, launch
caffeine
and its icon should appear in your system tray. You can choose which programs should cancel suspending.Note: As of the 2.7 release of caffeine, the program no longer has a GUI and works only as a daemon. When running, it will prevent the screensaver from activating so long as the active window is full screen.
The LightsOn script. It won't check spotify by default but it is easy enough to modify it to do so. Just add
spotify
to thedelay_progs
array at the beginging of the script:delay_progs=("spotify")
Then, add the script to your startup programs so it runs in the background. and it should stop you from suspending if spotify is running. Note that this does not check whether any music is playing, just whether the program is running.
Let me know if these don't work for the suspension and I'll try and hack something together using xdotool
or similar programs.
edited Jul 13 '16 at 22:24
polemon
5,48964076
5,48964076
answered Oct 4 '14 at 20:24
terdonâ¦
124k29233407
124k29233407
I've used caffeine and it's worked alright in the past. It seems buggy though since I've had it active and the screensaver would still kick in. Haven't debugged it further, though.
â slmâ¦
Oct 5 '14 at 15:29
@slm I haven't so I can't speak as to how well it works. The second solution, the shell script, looks very interesting. It's relatively straightforward and should be easy to expand to blocking suspension.
â terdonâ¦
Oct 5 '14 at 15:33
yeah I was just giving a recounting of my experience. 2nd solution is prob. A better approach to try.
â slmâ¦
Oct 5 '14 at 15:35
The script looks pretty good. Could you add a line to your answer showing how to run the script at start-up?
â LondonRob
Oct 6 '14 at 22:25
@LondonRob that depends on your desktop environment but for most it's something along the lines of settings => startup programs. That's where you can find it on Cinnamon for example. Alternatively, copy thecaffeine.desktop
file from/usr/share/applications
to~/.config/autostart/
.
â terdonâ¦
Oct 6 '14 at 22:39
 |Â
show 1 more comment
I've used caffeine and it's worked alright in the past. It seems buggy though since I've had it active and the screensaver would still kick in. Haven't debugged it further, though.
â slmâ¦
Oct 5 '14 at 15:29
@slm I haven't so I can't speak as to how well it works. The second solution, the shell script, looks very interesting. It's relatively straightforward and should be easy to expand to blocking suspension.
â terdonâ¦
Oct 5 '14 at 15:33
yeah I was just giving a recounting of my experience. 2nd solution is prob. A better approach to try.
â slmâ¦
Oct 5 '14 at 15:35
The script looks pretty good. Could you add a line to your answer showing how to run the script at start-up?
â LondonRob
Oct 6 '14 at 22:25
@LondonRob that depends on your desktop environment but for most it's something along the lines of settings => startup programs. That's where you can find it on Cinnamon for example. Alternatively, copy thecaffeine.desktop
file from/usr/share/applications
to~/.config/autostart/
.
â terdonâ¦
Oct 6 '14 at 22:39
I've used caffeine and it's worked alright in the past. It seems buggy though since I've had it active and the screensaver would still kick in. Haven't debugged it further, though.
â slmâ¦
Oct 5 '14 at 15:29
I've used caffeine and it's worked alright in the past. It seems buggy though since I've had it active and the screensaver would still kick in. Haven't debugged it further, though.
â slmâ¦
Oct 5 '14 at 15:29
@slm I haven't so I can't speak as to how well it works. The second solution, the shell script, looks very interesting. It's relatively straightforward and should be easy to expand to blocking suspension.
â terdonâ¦
Oct 5 '14 at 15:33
@slm I haven't so I can't speak as to how well it works. The second solution, the shell script, looks very interesting. It's relatively straightforward and should be easy to expand to blocking suspension.
â terdonâ¦
Oct 5 '14 at 15:33
yeah I was just giving a recounting of my experience. 2nd solution is prob. A better approach to try.
â slmâ¦
Oct 5 '14 at 15:35
yeah I was just giving a recounting of my experience. 2nd solution is prob. A better approach to try.
â slmâ¦
Oct 5 '14 at 15:35
The script looks pretty good. Could you add a line to your answer showing how to run the script at start-up?
â LondonRob
Oct 6 '14 at 22:25
The script looks pretty good. Could you add a line to your answer showing how to run the script at start-up?
â LondonRob
Oct 6 '14 at 22:25
@LondonRob that depends on your desktop environment but for most it's something along the lines of settings => startup programs. That's where you can find it on Cinnamon for example. Alternatively, copy the
caffeine.desktop
file from /usr/share/applications
to ~/.config/autostart/
.â terdonâ¦
Oct 6 '14 at 22:39
@LondonRob that depends on your desktop environment but for most it's something along the lines of settings => startup programs. That's where you can find it on Cinnamon for example. Alternatively, copy the
caffeine.desktop
file from /usr/share/applications
to ~/.config/autostart/
.â terdonâ¦
Oct 6 '14 at 22:39
 |Â
show 1 more comment
up vote
0
down vote
I just posted an answer for a similar question:
Linux Mint: How to Avoid Suspending While Music is Playing
I have written a script to set the suspend timeout to "Never" while pactl detects a running audio source, then reverts the setting when no audio sources are detected.
Here is a copy of the latest answer and script:
I have done a little more work on the above script and it should now work in Cinnamon, Mate and Ubuntu running Gnome. I have tried it out on Live USB versions of Linux Mint 19 Cinnamon and Mate as well as Ubuntu 18.04 - Gnome.
#!/bin/sh
# Audiocaffeine
# Works in Linux Mint 19 - Cinnamon, Linux Mint 19 - Mate, Ubuntu 18.04 - Gnome
# Script to temporarily set suspend timout for AC and battery to "Never"
# while audio is playing. It then reverts the settings when audio is no longer detected.
# Determine if a valid desktop environment is running and exit if it doesn't.
echo "Reported desktop environment: ""$XDG_CURRENT_DESKTOP"
if [ "$XDG_CURRENT_DESKTOP" = "X-Cinnamon" ]; then
actimeoutid="org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout"
batttimeoutid="org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout"
disablevalue=0
elif [ "$XDG_CURRENT_DESKTOP" = "MATE" ]; then
actimeoutid="org.mate.power-manager sleep-computer-ac"
batttimeoutid="org.mate.power-manager sleep-computer-battery"
disablevalue=0
elif [ "$XDG_CURRENT_DESKTOP" = "ubuntu:GNOME" ]; then
actimeoutid="org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type"
batttimeoutid="org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type"
disablevalue="nothing"
else
echo "No valid desktop environment is running"
exit 1
fi
# Create .config directory to store settings if it doesn't exist.
if [ ! -d ~/.config ]; then
echo ".config directory not found!"
echo "Creating ~/.config"
mkdir ~/.config
fi
# Create audiocaffeine 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 $actimeoutid $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 $batttimeoutid $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 "State: 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 $actimeoutid > ~/.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 $batttimeoutid > ~/.config/audiocaffeine/battsuspend
fi
# Set the suspend timouts to Never using gsettings.
echo "Changing suspend timeouts."
gsettings set $actimeoutid $disablevalue
gsettings set $batttimeoutid $disablevalue
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 $actimeoutid $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 $batttimeoutid $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
add a comment |Â
up vote
0
down vote
I just posted an answer for a similar question:
Linux Mint: How to Avoid Suspending While Music is Playing
I have written a script to set the suspend timeout to "Never" while pactl detects a running audio source, then reverts the setting when no audio sources are detected.
Here is a copy of the latest answer and script:
I have done a little more work on the above script and it should now work in Cinnamon, Mate and Ubuntu running Gnome. I have tried it out on Live USB versions of Linux Mint 19 Cinnamon and Mate as well as Ubuntu 18.04 - Gnome.
#!/bin/sh
# Audiocaffeine
# Works in Linux Mint 19 - Cinnamon, Linux Mint 19 - Mate, Ubuntu 18.04 - Gnome
# Script to temporarily set suspend timout for AC and battery to "Never"
# while audio is playing. It then reverts the settings when audio is no longer detected.
# Determine if a valid desktop environment is running and exit if it doesn't.
echo "Reported desktop environment: ""$XDG_CURRENT_DESKTOP"
if [ "$XDG_CURRENT_DESKTOP" = "X-Cinnamon" ]; then
actimeoutid="org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout"
batttimeoutid="org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout"
disablevalue=0
elif [ "$XDG_CURRENT_DESKTOP" = "MATE" ]; then
actimeoutid="org.mate.power-manager sleep-computer-ac"
batttimeoutid="org.mate.power-manager sleep-computer-battery"
disablevalue=0
elif [ "$XDG_CURRENT_DESKTOP" = "ubuntu:GNOME" ]; then
actimeoutid="org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type"
batttimeoutid="org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type"
disablevalue="nothing"
else
echo "No valid desktop environment is running"
exit 1
fi
# Create .config directory to store settings if it doesn't exist.
if [ ! -d ~/.config ]; then
echo ".config directory not found!"
echo "Creating ~/.config"
mkdir ~/.config
fi
# Create audiocaffeine 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 $actimeoutid $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 $batttimeoutid $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 "State: 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 $actimeoutid > ~/.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 $batttimeoutid > ~/.config/audiocaffeine/battsuspend
fi
# Set the suspend timouts to Never using gsettings.
echo "Changing suspend timeouts."
gsettings set $actimeoutid $disablevalue
gsettings set $batttimeoutid $disablevalue
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 $actimeoutid $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 $batttimeoutid $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
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I just posted an answer for a similar question:
Linux Mint: How to Avoid Suspending While Music is Playing
I have written a script to set the suspend timeout to "Never" while pactl detects a running audio source, then reverts the setting when no audio sources are detected.
Here is a copy of the latest answer and script:
I have done a little more work on the above script and it should now work in Cinnamon, Mate and Ubuntu running Gnome. I have tried it out on Live USB versions of Linux Mint 19 Cinnamon and Mate as well as Ubuntu 18.04 - Gnome.
#!/bin/sh
# Audiocaffeine
# Works in Linux Mint 19 - Cinnamon, Linux Mint 19 - Mate, Ubuntu 18.04 - Gnome
# Script to temporarily set suspend timout for AC and battery to "Never"
# while audio is playing. It then reverts the settings when audio is no longer detected.
# Determine if a valid desktop environment is running and exit if it doesn't.
echo "Reported desktop environment: ""$XDG_CURRENT_DESKTOP"
if [ "$XDG_CURRENT_DESKTOP" = "X-Cinnamon" ]; then
actimeoutid="org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout"
batttimeoutid="org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout"
disablevalue=0
elif [ "$XDG_CURRENT_DESKTOP" = "MATE" ]; then
actimeoutid="org.mate.power-manager sleep-computer-ac"
batttimeoutid="org.mate.power-manager sleep-computer-battery"
disablevalue=0
elif [ "$XDG_CURRENT_DESKTOP" = "ubuntu:GNOME" ]; then
actimeoutid="org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type"
batttimeoutid="org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type"
disablevalue="nothing"
else
echo "No valid desktop environment is running"
exit 1
fi
# Create .config directory to store settings if it doesn't exist.
if [ ! -d ~/.config ]; then
echo ".config directory not found!"
echo "Creating ~/.config"
mkdir ~/.config
fi
# Create audiocaffeine 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 $actimeoutid $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 $batttimeoutid $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 "State: 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 $actimeoutid > ~/.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 $batttimeoutid > ~/.config/audiocaffeine/battsuspend
fi
# Set the suspend timouts to Never using gsettings.
echo "Changing suspend timeouts."
gsettings set $actimeoutid $disablevalue
gsettings set $batttimeoutid $disablevalue
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 $actimeoutid $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 $batttimeoutid $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
I just posted an answer for a similar question:
Linux Mint: How to Avoid Suspending While Music is Playing
I have written a script to set the suspend timeout to "Never" while pactl detects a running audio source, then reverts the setting when no audio sources are detected.
Here is a copy of the latest answer and script:
I have done a little more work on the above script and it should now work in Cinnamon, Mate and Ubuntu running Gnome. I have tried it out on Live USB versions of Linux Mint 19 Cinnamon and Mate as well as Ubuntu 18.04 - Gnome.
#!/bin/sh
# Audiocaffeine
# Works in Linux Mint 19 - Cinnamon, Linux Mint 19 - Mate, Ubuntu 18.04 - Gnome
# Script to temporarily set suspend timout for AC and battery to "Never"
# while audio is playing. It then reverts the settings when audio is no longer detected.
# Determine if a valid desktop environment is running and exit if it doesn't.
echo "Reported desktop environment: ""$XDG_CURRENT_DESKTOP"
if [ "$XDG_CURRENT_DESKTOP" = "X-Cinnamon" ]; then
actimeoutid="org.cinnamon.settings-daemon.plugins.power sleep-inactive-ac-timeout"
batttimeoutid="org.cinnamon.settings-daemon.plugins.power sleep-inactive-battery-timeout"
disablevalue=0
elif [ "$XDG_CURRENT_DESKTOP" = "MATE" ]; then
actimeoutid="org.mate.power-manager sleep-computer-ac"
batttimeoutid="org.mate.power-manager sleep-computer-battery"
disablevalue=0
elif [ "$XDG_CURRENT_DESKTOP" = "ubuntu:GNOME" ]; then
actimeoutid="org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type"
batttimeoutid="org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type"
disablevalue="nothing"
else
echo "No valid desktop environment is running"
exit 1
fi
# Create .config directory to store settings if it doesn't exist.
if [ ! -d ~/.config ]; then
echo ".config directory not found!"
echo "Creating ~/.config"
mkdir ~/.config
fi
# Create audiocaffeine 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 $actimeoutid $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 $batttimeoutid $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 "State: 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 $actimeoutid > ~/.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 $batttimeoutid > ~/.config/audiocaffeine/battsuspend
fi
# Set the suspend timouts to Never using gsettings.
echo "Changing suspend timeouts."
gsettings set $actimeoutid $disablevalue
gsettings set $batttimeoutid $disablevalue
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 $actimeoutid $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 $batttimeoutid $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
edited Sep 7 at 23:00
Rui F Ribeiro
36.8k1273117
36.8k1273117
answered Aug 8 at 2:52
Jason Gambrel
212
212
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f159286%2fprevent-mint-from-suspending-while-playing-music-in-spotify%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
This solution looks relevant, but the links in the solution are dead at time of writing.
â LondonRob
Mar 22 '16 at 19:43