diff options
author | Justin Gassner <justin.gassner@mailbox.org> | 2023-08-25 17:55:32 +0200 |
---|---|---|
committer | Justin Gassner <justin.gassner@mailbox.org> | 2023-09-18 12:39:47 +0200 |
commit | 159003fd48ef797dc9ef9d52fc753bec8d8ff72b (patch) | |
tree | ff542e87318854a46c93a73d3d1ce202929a1947 /.config/mpv/scripts/turn-off-dpms.lua | |
parent | afb499d81dc22ccc00fbd999862360a3e6f16cdb (diff) | |
download | dotfiles-x1.tar.zst |
configx1
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) |