diff --git a/DOCS/man/mpv.rst b/DOCS/man/mpv.rst index 92c0052c557f..dbd700cc9eb7 100644 --- a/DOCS/man/mpv.rst +++ b/DOCS/man/mpv.rst @@ -1057,6 +1057,50 @@ works like in older mpv releases: change, and not apply your additional settings, and/or use a different profile name. +Linux desktop issues +==================== + +This subsection describes common problems on the Linux desktop. None of these +problems exist on systems like Windows or OSX. + +Disabling Screensaver +--------------------- + +By default, mpv tries to disable the OS screensaver during playback (only if +a VO using the OS GUI API is active). ``--stop-screensaver=no`` disables this. + +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 on Wayland. + +GNOME is one of the worst offenders, and ignores even the now widely supported +idle-inhibit protocol. (This is either due to a combination of malice and +incompetence, but since implementing this protocol would only take a few lines +of code, it is most likely the former. You will also notice how GNOME advocates +react offended whenever their sabotage is pointed out, which indicates either +hypocrisy, or even worse ignorance.) + +Such incompatible desktop environments (i.e. which ignore standards) typically +require using a DBus API. This is ridiculous in several ways. The immediate +practical problem is that it would require adding a quite unwieldy dependency +for a DBus library, somehow integrating its mainloop into mpv, and other +generally unacceptable things. + +However, since mpv does not officially support GNOME, this is not much of a +problem. If you are one of those miserable users who want to use mpv on GNOME, +report a bug on the GNOME issue tracker: +https://gitlab.gnome.org/groups/GNOME/-/issues + +Alternatively, you may be able to write a Lua script that calls the +``xdg-screensaver`` command line program. (By the way, this a command line +program is an utterly horrible kludge that tries to identify your DE, and then +tries to send the correct DBus command via a DBus CLI tool.) If you find the +idea of having to write a script just so your screensaver doesn't kick in +ridiculous, do not use GNOME, or use GNOME video software instead of mpv (good +luck). + +Before mpv 0.33.0, the X11 backend ran ``xdg-screensaver reset`` in 10 second +intervals when not paused. This hack was removed in 0.33.0. .. include:: options.rst diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index ce0f19e1135d..f554186f041f 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -3147,7 +3147,8 @@ Window always re-enabled when the player is paused. This is not supported on all video outputs or platforms. Sometimes it is - implemented, but does not work (especially with Linux "desktops"). + implemented, but does not work (especially with Linux "desktops"). Read the + `Disabling Screensaver`_ section very carefully. ``--wid=`` This tells mpv to attach to an existing window. If a VO is selected that diff --git a/video/out/x11_common.c b/video/out/x11_common.c index 9b326674dce3..40228903b93d 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -527,30 +527,6 @@ static void vo_x11_get_bounding_monitors(struct vo_x11_state *x11, long b[4]) XFree(screens); } -static void *screensaver_thread(void *arg) -{ - struct vo_x11_state *x11 = arg; - - for (;;) { - sem_wait(&x11->screensaver_sem); - // don't queue multiple wakeups - while (!sem_trywait(&x11->screensaver_sem)) {} - - if (atomic_load(&x11->screensaver_terminate)) - break; - - char *args[] = {"xdg-screensaver", "reset", NULL}; - int status = mp_subprocess(args, NULL, NULL, mp_devnull, mp_devnull, &(char*){0}); - if (status) { - MP_VERBOSE(x11, "Disabling screensaver failed (%d). Make sure the " - "xdg-screensaver script is installed.\n", status); - break; - } - } - - return NULL; -} - int vo_x11_init(struct vo *vo) { char *dispName; @@ -572,13 +548,6 @@ int vo_x11_init(struct vo *vo) x11->opts = x11->opts_cache->opts; vo->x11 = x11; - sem_init(&x11->screensaver_sem, 0, 0); - if (pthread_create(&x11->screensaver_thread, NULL, screensaver_thread, x11)) { - sem_destroy(&x11->screensaver_sem); - goto error; - } - x11->screensaver_thread_running = true; - x11_error_output = x11->log; XSetErrorHandler(x11_errorhandler); @@ -808,13 +777,6 @@ void vo_x11_uninit(struct vo *vo) XCloseDisplay(x11->display); } - if (x11->screensaver_thread_running) { - atomic_store(&x11->screensaver_terminate, true); - sem_post(&x11->screensaver_sem); - pthread_join(x11->screensaver_thread, NULL); - sem_destroy(&x11->screensaver_sem); - } - if (x11->wakeup_pipe[0] >= 0) { close(x11->wakeup_pipe[0]); close(x11->wakeup_pipe[1]); @@ -2013,7 +1975,6 @@ static void xscreensaver_heartbeat(struct vo_x11_state *x11) (time - x11->screensaver_time_last) >= 10) { x11->screensaver_time_last = time; - sem_post(&x11->screensaver_sem); XResetScreenSaver(x11->display); } } diff --git a/video/out/x11_common.h b/video/out/x11_common.h index fffc5be2946a..774a76afbeb8 100644 --- a/video/out/x11_common.h +++ b/video/out/x11_common.h @@ -20,14 +20,11 @@ #include #include -#include #include #include -#include "osdep/atomic.h" -#include "osdep/semaphore.h" - #include "common/common.h" +#include "osdep/atomic.h" #include "config.h" #if !HAVE_GPL @@ -75,10 +72,6 @@ struct vo_x11_state { bool screensaver_enabled; bool dpms_touched; double screensaver_time_last; - pthread_t screensaver_thread; - bool screensaver_thread_running; - sem_t screensaver_sem; - atomic_bool screensaver_terminate; XIM xim; XIC xic;