LINUX.ORG.RU

Напишем скрипт на lua для mpv?

 , , , ,


0

1
Linux desktop issues

This subsection describes common problems on the Linux desktop. None of these problems exist on systems like Windows or macOS.
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.

Неееетттт xD

cat scripts/xscreensaver.lua

local utils = require 'mp.utils'
mp.add_periodic_timer(30, function()
    utils.subprocess({args={"xdg-screensaver", "reset"}})
end)

но на паузе надо бы, чтобы скринсейвер таки включался. Кто любитель lua? Кто возьмётся довести до нормального состояния?

★★★

Сам напиши. Жопа ты ленивая :3

  -- узнать стоит ли плеер на паузе
  mp.get_property_native("pause")
  -- а теперь нагугли как в lua использовать if/else 
  -- и используя твой скрипт вырубай скринсейвер
  -- тебе надо прямо в эту функцию с 30 секундным таймером
  -- довабить if/else 
anonymous
()
Ответ на: комментарий от anonymous

Как же хочется, чтобы зашел такой и «родные мои, напишите скрипт!!». А фиг! Пейши сам. Сам так сам, окей:(

local rs_enabled = true
local rs_timeout = 30
local utils = require 'mp.utils'

function rs_toggle()
   if rs_enabled then
      utils.subprocess({args={"xdg-screensaver", "reset"}})
      -- mp.msg.log("info", 111111111111111111111111111111111111111")
   end
end

function rs_disable()
    if rs_enabled then
        rs_enabled = false
    end
end

function rs_enable()
    if not rs_enabled then
        rs_enabled = true
    end
end

function rs_handler()
    if mp.get_property("video") ~= "no" then
        rs_enable()
    else
        rs_disable()
   end
end


function on_pause_change(name, value)
    if value then  --pause started
        rs_disable()
    else
        rs_enable()
    end
end


mp.register_event("file-loaded", rs_handler)
mp.register_event("shutdown", rs_disable)
mp.observe_property("pause", "bool", on_pause_change)
mp.add_periodic_timer(rs_timeout, rs_toggle)
serg002 ★★★
() автор топика

Для Linux? Не, не интересно. Даже если заплатят. (%

mord0d ★★★★★
()
Ответ на: комментарий от serg002

Вот! Молодец. А я луу сам то не знаю, нагуглил просто и тебе вскинул ыгыгыгыг. В любом случае я тоже молодец. Глядишь так программиста воспитаю! Ух =)

anonymous
()

К слову, попробуй cinnamon из него можно сделать гном, в нем можно и нужно использовать стек приложений гнома. Зато нет таких костылей, всё работает из коробки ион быстрее гнома в разы. Обзор окон и рабочих столов в десяток раз удобнее и настраивается из коробки.

anonymous
()
Ответ на: комментарий от anonymous

Гном срет на стандарты на любом дистре

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.