You are not logged in.

#1 2024-03-31 17:12:02

002445
Member
Registered: 2021-10-07
Posts: 10

[SOLVED] Using MPV once disables screensaver until reboot.

I have connected a PC running arch to my TV to watch movies using MPV. It works great, I can start movies over SSH and I can even send the keystrokes over SSH to do anything in MPV (change volume, subtitle adjustments, change audio, etc) . So my laptop is my remote.

The only issue I run into is that when I open MPV once, the screensaver seems to get disabled until I reboot my system.

If I do a fresh boot and don't run MPV and the system is idle for 15 minutes the screen goes blank after which the TV will turn off in 5 minutes because there is no signal, pretty perfect energy wise.

If I run MPV once to play a media file the system will not go into screensaver mode, no matter how long it is idle. I would expect the system to go into screensaver mode 15 minutes after the media file is finished playing.

I use i3WM as my window manager if it matters and the installation was done using the archinstall script from the USB installer and I have not installed any screensaver software or changed any settings related to energy savings.

Has anyone run into this problem and have a solution? Thanks in advance!

PS. Bonus points for anyone knowing how I can change the screensaver timer from the default 15 minutes.

Last edited by 002445 (2024-03-31 19:13:23)

Offline

#2 2024-03-31 17:37:23

seth
Member
Registered: 2012-09-03
Posts: 51,608

Re: [SOLVED] Using MPV once disables screensaver until reboot.

https://man.archlinux.org/man/extra/mpv/mpv.1.en#stop~2

Bonus

xset q
xset h

and you can also configure them in your xorg config, https://wiki.archlinux.org/title/Displa … _Signaling

Offline

#3 2024-03-31 18:22:15

002445
Member
Registered: 2021-10-07
Posts: 10

Re: [SOLVED] Using MPV once disables screensaver until reboot.

Thank you, I was able to change the screensaver timer to 5 minutes by following the instructions and made the file `/etc/X11/xorg.conf,d/10-monitor.conf` with only the following contents:

Section "ServerFlags"
    Option "StandbyTime" "5"
EndSection

Sadly MPV still overrides this once it's been opened. I also tried adding the other options:

Option "SuspendTime" "10"
Option "OffTime" "15"

But they also didn't work after MPV was opened.

Offline

#4 2024-03-31 19:12:53

002445
Member
Registered: 2021-10-07
Posts: 10

Re: [SOLVED] Using MPV once disables screensaver until reboot.

Okay I was able to use the first link to create a solution.

If you run the command `·xdg-screensaver reset` the screensaver will work again.

So I made a Fish shell script (yes I use Fish, fight me).

function m
    mpv $argv
    xdg-screensaver reset
end

This lets me use mpv with 2 less keystrokes and works with both YouTube videos and local media, after which the screensaver is reset. Both when quiting the media manually and letting it finish by itself. So my problem is solved. If anyone has a more elegant solution I am still curious but for now I'll mark this as Solved.

Thanks again Seth!

Offline

#5 2024-03-31 21:23:17

seth
Member
Registered: 2012-09-03
Posts: 51,608

Re: [SOLVED] Using MPV once disables screensaver until reboot.

https://man.archlinux.org/man/extra/mpv … creensaver ?

Are you sure you're not somehow running mpv --stop-screensaver=always?
What's the impact on "xset q" wrt the screensaver and dpms timeouts when running mpv?

Offline

#6 2024-04-01 05:38:35

002445
Member
Registered: 2021-10-07
Posts: 10

Re: [SOLVED] Using MPV once disables screensaver until reboot.

Up until I made my script from my previous post I ran mpv directly from my terminal over SSH. For example:

mpv https://www.youtube.com/watch?v=EVoUFc_oIms

my mpv.conf only contains:

demuxer-max-bytes=2000000KiB
ytdl-raw-options=yes-playlist=

And when running MPV and checking the output of `ps aux` I just see:

media       7392 11.9  1.3 2391152 222344 pts/1  SLl+ 07:24   0:01 mpv https://www.youtube.com/watch?v=EVoUFc_oIms

So I highly doubt there is any way for the `--stop-screensaver=always` flag to be used without me knowing about it.

If I run `xset q` I get the following output:

Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  600    cycle:  600

DPMS (Display Power Management Signaling):
  Standby: 300    Suspend: 600    Off: 600
  DPMS is Enabled
  Monitor is On

Which seems fine, once the monitor goes to sleep the output only changes on the last line to:

  Monitor is in Standby

In the article you linked it states:

> A common problem is that Linux desktop environments ignore the standard screensaver APIs on which mpv relies. In particular, mpv uses the Screen Saver extension (XSS) on X11, and the idle-inhibit protocol on Wayland.

and

>  Sometimes it is implemented, but does not work (especially with Linux "desktops"). Read the Disabling Screensaver section very carefully.

So it seems like on some setups it simply doesn't work to re-enable the screensaver after the media finishes playing. I could try a different WM than i3, maybe even try one with wayland like Sway but I can live with using a shell script to call MPV. Switching WM would be quite a pain.

Interestingly on my laptops running i3wm with arch I do not have this problem, the only difference is that the Media PC uses a dedicated AMD GPU (RX480) instead of an intel integrated GPU which both my laptops have. So I guess the disclaimer that this might not always work in the link you sent could refer to setups with an AMD GPU in combination with i3WM.

The driver(s) I am using are:

extra/vulkan-radeon 1:24.0.3-2 [installed]
    Open-source Vulkan driver for AMD GPUs

extra/xf86-video-amdgpu 23.0.0-1 (xorg-drivers) [installed]
    X.org amdgpu video driver

Last edited by 002445 (2024-04-01 05:49:22)

Offline

#7 2024-04-01 07:07:13

seth
Member
Registered: 2012-09-03
Posts: 51,608

Re: [SOLVED] Using MPV once disables screensaver until reboot.

So I highly doubt there is any way for the `--stop-screensaver=always` flag to be used without me knowing about it.

Anything else in ~/.config/mpv/* ?

So it seems like on some setups it simply doesn't work to re-enable the screensaver after the media finishes playing.

I have not installed any screensaver software or changed any settings related to energy savings.

would suggest that it's not any specific screesaver implementation but "just" DPMS.
(Do you get a lock screen?)

Interestingly on my laptops running i3wm with arch I do not have this problem

the screensaver seems to get disabled until I reboot my system

Is very unlikely to be a driver problem - if anything special causes your situation then it's the ssh part (have you tried to reproduce the behavior locally?)

Offline

#8 2024-04-01 08:08:06

002445
Member
Registered: 2021-10-07
Posts: 10

Re: [SOLVED] Using MPV once disables screensaver until reboot.

the only other file is the input.conf containing:

MBTN_RIGHT    ignore

WHEEL_UP     ignore
WHEEL_DOWN   ignore
WHEEL_LEFT   ignore
WHEEL_RIGHT  ignore

h seek -5
j add volume -2
k add volume 2
l seek 5

g set time-pos 0
q quit-watch-later

I don't get a lock screen, the output just drops so the TV shows the 'no device connected, turning off in 5 minutes' message. Which is how I want it. Opening a new media file turns the output back on so the PC itself is not in any sort of standby. All network connections remain connected.

I just tried playing a file directly and killed all SSH connections before and the screensaver does work that way. So running `mpv file.mkv' over SSH disables the screensaver until I run `xdg-screensaver reset` or reboot but running that same command locally without any SSH connections doesn't disable the screensaver.

We seem to be getting closer to the real issue. Just to make sure it is clear, connecting over SSH and keeping the SSH connection open does not disable the screensaver. It seems to be the combination of starting MPV over SSH that disables the screensaver.

Offline

#9 2024-04-01 08:54:02

seth
Member
Registered: 2012-09-03
Posts: 51,608

Re: [SOLVED] Using MPV once disables screensaver until reboot.

the output just drops so the TV shows the 'no device connected

That's DPMS.

It seems to be the combination of starting MPV over SSH that disables the screensaver.

Yup.
What if you run a tmux instance in the GUI context of the PC and attach to the tmux session from the ssh login and run mpv out of that?
Didn't you have to direct mpv towards using the proper X11 server from your ssh login anyway?

And, semi-related, you're aware of kodi?

Offline

#10 2024-04-01 09:16:29

002445
Member
Registered: 2021-10-07
Posts: 10

Re: [SOLVED] Using MPV once disables screensaver until reboot.

I do have tmux running on the Media PC so I attach to that session from both laptops or even an app from my phone if I wanted. My fish config file sets the display variable that is needed for this to work yes.

set -x DISPLAY ":0"

is what I use, for Bash I think it would be

export DISPLAY=":0"

I know about Kodi but the downside is how to control it. I could use a keyboard connected to the PC but using a laptop is much superior ergonomically from a couch than a keyboard. I also prefer the flexibility of MPV so I can easily open anything I want. How would browsing YouTube from within Kodi with a keyboard work?

Now I can just browse around on my laptop and if I find anything worthwhile hit ALT+M which brings the terminal with the SSH connection to the front (I use the i3 scratchpad to hide the terminal) and type m and paste the YouTube link and it'll start playing. I can easily play playlists or just play an entire season of a show with 1 command `m (ls *mkv)` from the season folder.

I didn't expect this at the start but when the terminal is in focus all keystrokes known to MPV are sent over it so I can seek forward with l, change subtitles with J, quit the video and save the playback location with q, etc. Its perfect.

Once it's done playing everything will turn off again. After using Plex and Kodi years ago I must say this is so much better.

Last thing I want to check out is minimizing the VP9 usage when watching YouTube since my GPU doesn't have hardware acceleration for that codec. I found some ways to disable VP9 all the time but then nothing is shown in 4k anymore. I'd still like to be able to watch 4k content from YouTube now and then.

But that is a small optimization I'll look at next week or something.

Offline

#11 2024-04-01 15:59:20

seth
Member
Registered: 2012-09-03
Posts: 51,608

Re: [SOLVED] Using MPV once disables screensaver until reboot.

ytdl-raw-options='live-from-start=,format="mp4,best[height<=1080]"'

How exactly do you start tmux if you've to explicitly set the DISPLAY?
System service for the user?

The idea would have been to start tmux out of the GUI session on the PC and attach to that (though it's weird that mpv manages to turn off the DPMS, but not on again)

Offline

#12 2024-04-01 16:07:17

002445
Member
Registered: 2021-10-07
Posts: 10

Re: [SOLVED] Using MPV once disables screensaver until reboot.

I use the following in my config.fish on the Media PC

# check if tmux is running
set tmuxpid (pgrep tmux)

# open tmux if it is not running
if test -z "$tmuxpid"
    tmux
end

So after a reboot it will open tmux on the first SSH connection, if I reconnect or connect from a different device I use `tmux attach` to connect to the running session.

Offline

#13 2024-04-01 16:14:39

seth
Member
Registered: 2012-09-03
Posts: 51,608

Re: [SOLVED] Using MPV once disables screensaver until reboot.

Please use [code][/code] tags.

Ok, don't strat tmux from ssh, but (try to) start it manually on the GUI session opening a terminal there should be enough)

Offline

#14 2024-04-01 17:10:54

002445
Member
Registered: 2021-10-07
Posts: 10

Re: [SOLVED] Using MPV once disables screensaver until reboot.

Starting tmux from the PC does the trick, the screensaver starts 5 minutes after media is finished playing. In my case I prefer to run MPV from my small script which runs

xdg-screensaver reset

after playing media just so I don't have to touch the Media PC after a reboot but it might help people with the same issue stumbling on this post to know the source of the issue.

Thanks for all the help!

Offline

Board footer

Powered by FluxBB