You are not logged in.

#1 2023-05-28 17:41:31

chowder
Member
Registered: 2023-05-28
Posts: 2

Laptop suspends while mpd is playing

...and I'd like to change that.

I want to prevent only sleep/hibernation which activates automatically after some idle time - not the screensaver function.

I have installed a simple wm-only system under Xorg. It works as expected otherwise. It uses xfce4-power-manager.

mpd is started through the provided systemd --user service.
I could start it with systemd-inhibit, but I want to stop the system from going to sleep only when mpd is playing something, not all the time it is up.

I have changed mpd's output from ALSA to pulse, to no avail.

I just spend ~2h searching around and found nothing satisfactory (closest was something about dBus calls which is a bit above my capabilities).
If this cannot be solved from within mpd or pulseaudio, I can write a small daemon script to check if mpd is playing something (easy), and tell systemd (?) to not go to sleep right now (???).

Any ideas?

$ grep -vE '[[:space:]]*#|^$' .config/mpd/mpd.conf
music_directory		"~/Music"
playlist_directory		"~/.config/mpd/playlists"
db_file			"~/.config/mpd/database"
pid_file			"~/.config/mpd/pid"
state_file			"~/.config/mpd/state"
sticker_file			"~/.config/mpd/sticker.sql"
bind_to_address		"localhost"
port				"6600"
restore_paused "yes"
save_absolute_paths_in_playlists	"yes"
auto_update	"yes"
zeroconf_enabled		"no"
input_cache {
    size "1 GB"
}
audio_output {
	type		"pulse"
	name		"MPD"
}

Nothing exciting, locally stored music only.

TIA

Offline

#2 2023-05-28 19:29:37

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,244

Re: Laptop suspends while mpd is playing

idk. whether you can hook scripts out of mpd actions, but you could certainly poll mpd, see whether it's playing something and un/inhibit the S3 based on the status?

while read line; do mpc status | grep playing > /dev/null 2>&1 && echo inhibit || echo snorlax; done < <(mpc idleloop player)

Offline

#3 2023-05-29 19:10:00

chowder
Member
Registered: 2023-05-28
Posts: 2

Re: Laptop suspends while mpd is playing

Yes, that's the easy part.

But how I can implement "inhibit sleep, but only until the next test"?

Offline

#4 2023-05-29 19:39:27

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,244

Re: Laptop suspends while mpd is playing

You can just fork a 512 day sleep save the PID and kill it when the playback stops ?

Offline

Board footer

Powered by FluxBB