diff options
Diffstat (limited to '')
| -rw-r--r-- | .config/mpv/scripts/hooks.lua | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/.config/mpv/scripts/hooks.lua b/.config/mpv/scripts/hooks.lua index 902846e..4f350ec 100644 --- a/.config/mpv/scripts/hooks.lua +++ b/.config/mpv/scripts/hooks.lua @@ -1,7 +1,7 @@ local mp = require("mp") local utils = require("mp.utils") -local run = function(...) +local function run(...) utils.subprocess_detached({ args = { "sh", "-c", table.concat({ ... }, " ") .. " >/dev/null 2>&1" }, max_size = 0, @@ -9,21 +9,19 @@ local run = function(...) }) 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") +mp.register_event("file-loaded", function() + local function cb(n, vo) + -- mp.msg.warn(n, vo) + if vo == true then + run("makoctl", "mode", "-a", "off") + run("svdn", "wlsunset") + mp.unobserve_property(cb) + end end + mp.observe_property("vo-configured", "bool", cb) end) mp.register_event("shutdown", function() run("makoctl", "mode", "-r", "off") - if has_video() then - run("svup", "wlsunset") - end + run("svup", "wlsunset") end) |