diff options
author | Justin Gassner <justin.gassner@mailbox.org> | 2024-01-10 13:29:11 +0100 |
---|---|---|
committer | Justin Gassner <justin.gassner@mailbox.org> | 2024-01-10 13:29:11 +0100 |
commit | 0dfdabd3d7c2aaee37900103c37a96317f3ada07 (patch) | |
tree | fe27ea564b60cf6e75b7f2dc3dc8bb57d78a3884 /.config/mpv/scripts/turn-off-dpms.lua | |
parent | 2a610aeff4a33456c03f0c8db1469cdc95ba1e73 (diff) | |
download | dotfiles-0dfdabd3d7c2aaee37900103c37a96317f3ada07.tar.zst |
config
Diffstat (limited to '.config/mpv/scripts/turn-off-dpms.lua')
-rw-r--r-- | .config/mpv/scripts/turn-off-dpms.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/.config/mpv/scripts/turn-off-dpms.lua b/.config/mpv/scripts/turn-off-dpms.lua new file mode 100644 index 0000000..d20a99e --- /dev/null +++ b/.config/mpv/scripts/turn-off-dpms.lua @@ -0,0 +1,45 @@ +-- originally written by nilninull + +local dpms_mod = nil + +local function on_property_change(name, value) + print("RUN on property change", value, dpms_mod) + if dpms_mod == nil and value then + -- This code was checked on xset 1.2.3 + if os.execute("[ `xset q | sed -n '/^DPMS/,${/^ DPMS/s/^ DPMS is //p}'` == Enabled ]") == 0 then + dpms_mod = true + else + dpms_mod = false + end + end +end + +mp.observe_property("vo-configured", "bool", on_property_change) + +local function dpms_mod_stop(event) + if dpms_mod then + os.execute("xset +dpms") + end +end + +mp.register_event("shutdown", dpms_mod_stop) + +local function dpms_on_play(event) + if dpms_mod then + os.execute("xset -dpms") + end +end + +mp.register_event("playback-restart", dpms_on_play) + +local function dpms_on_pause(name, value) + if dpms_mod then + if value then + os.execute("xset +dpms") + else + os.execute("xset -dpms") + end + end +end + +mp.observe_property("pause", "bool", dpms_on_pause) |