diff options
author | Anton Khirnov <anton@khirnov.net> | 2021-11-16 08:58:21 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2021-11-16 08:58:21 +0100 |
commit | d032ee43893eb04ec752354167bd262cf8430b5b (patch) | |
tree | ea385bf96a35f59da8a2fbcb1a69e1e8691add4f /mpv | |
parent | 9f0a029edae359c2b42cfc4ffa0bb476c5782246 (diff) |
mpv: add a script for disabling xscreensaver during video playback
Diffstat (limited to 'mpv')
-rw-r--r-- | mpv/xscreensaver.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mpv/xscreensaver.lua b/mpv/xscreensaver.lua new file mode 100644 index 0000000..4fbb41c --- /dev/null +++ b/mpv/xscreensaver.lua @@ -0,0 +1,24 @@ +-- this script periodically deactivates xscreensaver +-- when video playback is active + +local function heartbeat() + if mp.get_property_native("pause") or + mp.get_property_native("idle") or + not mp.get_property_native("vo-configured") then + return + end + + mp.command_native_async( + { + name = "subprocess", + args = { "xscreensaver-command", "-deactivate" }, + capture_stdout = true, + }, + function () end) +end + +mp.add_periodic_timer(60, heartbeat) + +for _, prop in ipairs({"pause", "idle", "vo-configured"}) do + mp.observe_property(prop, nil, heartbeat) +end |