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 | |
parent | 9f0a029edae359c2b42cfc4ffa0bb476c5782246 (diff) |
mpv: add a script for disabling xscreensaver during video playback
-rw-r--r-- | desktop.conf.yaml | 2 | ||||
-rw-r--r-- | mpv/xscreensaver.lua | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/desktop.conf.yaml b/desktop.conf.yaml index 292e8c6..e7242c2 100644 --- a/desktop.conf.yaml +++ b/desktop.conf.yaml @@ -1,9 +1,11 @@ - create: - ~/.config/mpv + - ~/.config/mpv/scripts - ~/.urxvt/ext - link: ~/.config/mpv/config: dotfiles/mpv + ~/.config/mpv/scripts/xscreensaver.lua: mpv/xscreensaver.lua ~/.local/bin/brightness_monitor: bin/brightness_monitor ~/.local/bin/randr_output_toggle: bin/randr_output_toggle ~/.local/bin/ssh_sk_clean: bin/ssh_sk_clean 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 |