diff options
| author | Robert Günzler <r@gnzler.io> | 2025-04-30 13:27:37 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2025-04-30 13:27:37 +0200 |
| commit | 92bd1ec4820b104d3d59371ffd9c17fc9ddef1a3 (patch) | |
| tree | 89ce8aa5c49d8ecb130df0d032a7a682c2697cac /.config/mpv/scripts | |
| parent | eb5a978e6f1de941fec2cbd97644036edcf52c38 (diff) | |
mpv: update
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '.config/mpv/scripts')
| -rw-r--r-- | .config/mpv/scripts/hooks.lua | 24 | ||||
| -rw-r--r-- | .config/mpv/scripts/mouse_coords.lua | 20 |
2 files changed, 26 insertions, 18 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) diff --git a/.config/mpv/scripts/mouse_coords.lua b/.config/mpv/scripts/mouse_coords.lua index 3bc59b9..b2a2a65 100644 --- a/.config/mpv/scripts/mouse_coords.lua +++ b/.config/mpv/scripts/mouse_coords.lua @@ -1,4 +1,4 @@ -local msg = require('mp.msg') +local msg = require("mp.msg") -- local x, y = 0, 0 @@ -20,10 +20,20 @@ local msg = require('mp.msg') -- end function print_pos() - x, y = mp.get_mouse_pos() - pos = "xy: " .. x .. "," .. y - mp.msg.warn(pos) - mp.osd_message(pos) + dw = mp.get_property_number("dwidth") + dh = mp.get_property_number("dheight") + ow, oh = mp.get_osd_size() + + wr = math.floor(ow / dw) + hr = math.floor(oh / dh) + + mx, my = mp.get_mouse_pos() + x = math.floor(mx / wr) + y = math.floor(my / hr) + + pos = dw .. "x" .. dh .. " " .. x .. "," .. y + mp.msg.warn(pos) + mp.osd_message(pos) end mp.add_key_binding("0", mp.get_script_name(), print_pos) |