diff options
Diffstat (limited to '')
| -rw-r--r-- | .config/mpv/scripts/hooks.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/.config/mpv/scripts/hooks.lua b/.config/mpv/scripts/hooks.lua new file mode 100644 index 0000000..902846e --- /dev/null +++ b/.config/mpv/scripts/hooks.lua @@ -0,0 +1,29 @@ +local mp = require("mp") +local utils = require("mp.utils") + +local run = function(...) + utils.subprocess_detached({ + args = { "sh", "-c", table.concat({ ... }, " ") .. " >/dev/null 2>&1" }, + max_size = 0, + cancellable = false, + }) +end + +local has_video = function() + local v = mp.get_property("video") + return v and v ~= "no" and v ~= "" +end + +mp.register_event("start-file", function() + run("makoctl", "mode", "-a", "off") + if has_video() then + run("svdn", "wlsunset") + end +end) + +mp.register_event("shutdown", function() + run("makoctl", "mode", "-r", "off") + if has_video() then + run("svup", "wlsunset") + end +end) |