How do i stop the auto-suspend when music player (strawberry/clementine) is playing?

I have searched and found a few scripts that don’t work and some mentions from a couple of years ago at Inhibit suspend when Clementine is playing music on KDE. But apart from manually clicking the “battery and Brightness” tray icon and then clicking “Manually block sleep and screen locking,” I can’t figure out a way to do it.

I don’t mind clicking the tray setting, but I always forget. I start some
music, go elsewhere in the house to work while listening via Bluetooth, and then it stops playing. I curse myself for forgetting to prevent it from sleeping again. I’m used to operating systems doing this automatically when a browser video or a media player is playing.

check

systemsettings → energy → enhanced energysetting and unmark “stop mediaplayer in standby”

I see an option that will stop the music player from playing when the system is wanting to suspend (Pause media players when suspending:) but not the other way around (stop it from suspending when player is playing)

check the energysaving → standby → change mode
you can set it to log off but keep the system alive.

I think you are using an older version of system setting, this is what mine looks like. It has no “standby”, it has Suspend session but only a choice of time and what to do (sleep/hibernate/switch off/ etc).

well this could be one way but i suspect there must be a programmatic way to tick/untick the “Manually block sleep and screen locking” tickbox in the tray under “Battery and brightness” which would be much better than moving the mouse back and forth every few seconds?

#! /bin/bash
State=1
while [ State != 0 ]; do

if pacmd list-sink-inputs | grep -c 'state: RUNNING'; then
let State=1
#echo "Playing"
xdotool mousemove_relative -- -1 -1
sleep 11m
xdotool mousemove_relative 1 1
sleep 11m
else
let State=0
#echo "Idle"
fi

done

Anyone know the command to do that? thx.

Try this:
systemd-inhibit may be used to execute a program with a shutdown,
sleep, or idle inhibitor lock taken. The lock will be acquired
before the specified command line is executed and released
afterwards.

e.g. in konsole, command:
systemd-inhibit clementine (I use it with the sayonara music player)

3 Likes

Ah, excellent. That was just want the doctor ordered :smile:

Thank you !

Another possibility is caffeine-ng available from the extra repository:

sudo pacman -S caffeine-ng

I have it set to autostart (icon in system tray) and enable it as needed to prevent sleep/etc. Although systemd-inhibit seems ideal for your needs, caffeine-ng may be of interest to passers-by. Cheers.

2 Likes

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.