You are not logged in.

#1 2021-03-21 10:47:12

terriblelizard
Member
Registered: 2021-03-21
Posts: 2

Prevent display turn off when playing music in terminal

When I play music in terminal music players such as cmus and musikcube and go about my non-computer business, the computer is assumed idle and my screen turns off after the time set by xorg-xset (600 s). This behavior is unwanted because my audio goes via HDMI to my TV's speaker system, and when the screen goes blank it switches to the rather screeching laptop speakers.

Media players such as mpv clearly can play media while not setting the state to idle, and thus prevent the screen from going blank. The above mentioned terminal music players don't do this by default and I cannot find anything in the settings to suggest that they can.

I suspect there is a clever solution around the problem, such as monitoring the state of the terminal music player via some third-party script, but my Linux chops are not up to par. and besides, it seems a rather convoluted solution to a simple problem. I'm prepared to admit that I'm missing something obvious, but please do point the way if you know it.

Cheers.

Offline

#2 2021-03-21 11:39:33

Zom
Member
From: Sweden
Registered: 2007-10-27
Posts: 430

Re: Prevent display turn off when playing music in terminal

You might be able to do something with xdg-screensaver, although I haven't tried it myself

Offline

#3 2021-03-21 13:13:41

terriblelizard
Member
Registered: 2021-03-21
Posts: 2

Re: Prevent display turn off when playing music in terminal

Zom wrote:

You might be able to do something with xdg-screensaver, although I haven't tried it myself

Thanks for that pointer. I found that xdg-screensaver suspends the screensaver using X window IDs, which is available in the shell environment as $WINDOWID.

So for e.g. cmus I can make the following alias to prevent the screen turning off as long as the terminal with the program is open:

alias cmus='xdg-screensaver suspend $WINDOWID && cmus && xdg-screensaver resume $WINDOWID'

It's an ad-hoc solution and I miss the functionality of detecting actual playback, but I guess it works for now.

Offline

#4 2021-03-21 13:33:27

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,001
Website

Re: Prevent display turn off when playing music in terminal

I wrote a script for this exact purpose few months back, check it out:

https://bbs.archlinux.org/viewtopic.php … 5#p1951595

Offline

Board footer

Powered by FluxBB