From 92bd1ec4820b104d3d59371ffd9c17fc9ddef1a3 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 30 Apr 2025 13:27:37 +0200 Subject: mpv: update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- .config/mpv/config | 4 ++-- .config/mpv/input.conf | 4 ++-- .config/mpv/mvi/input.conf | 6 +++++- .config/mpv/mvi/scripts/mouse_coords.lua | 1 + .config/mpv/scripts/hooks.lua | 24 +++++++++++------------- .config/mpv/scripts/mouse_coords.lua | 20 +++++++++++++++----- 6 files changed, 36 insertions(+), 23 deletions(-) create mode 120000 .config/mpv/mvi/scripts/mouse_coords.lua (limited to '.config') diff --git a/.config/mpv/config b/.config/mpv/config index 3c29e9b..8e43c38 100644 --- a/.config/mpv/config +++ b/.config/mpv/config @@ -11,7 +11,7 @@ cache=yes # vo=gpu-next # hwdec=auto-copy -hwdec=auto +hwdec=vaapi gpu-context=waylandvk gpu-api=vulkan # framedrop=decoder+vo @@ -79,7 +79,7 @@ cursor-autohide-fs-only keep-open=yes stop-screensaver=yes load-stats-overlay=yes -load-osd-console=yes +load-console=yes keepaspect-window=yes autofit-larger=x50% # osd-scale-by-window=no diff --git a/.config/mpv/input.conf b/.config/mpv/input.conf index d55414a..9407fda 100644 --- a/.config/mpv/input.conf +++ b/.config/mpv/input.conf @@ -89,8 +89,8 @@ Q quit-watch-later #! watch later # Ctrl+BS revert-seek mark-permanent -] script-binding skip2silence #! utils > skip2silence -} script-binding skip2scene #! utils > skip2scene +Alt+] script-binding skip2silence #! utils > skip2silence +Alt+} script-binding skip2scene #! utils > skip2scene u revert-seek mark-permanent #! controls > undo/revert seek = add volume 10 diff --git a/.config/mpv/mvi/input.conf b/.config/mpv/mvi/input.conf index 0eb9f48..1d5b989 100644 --- a/.config/mpv/mvi/input.conf +++ b/.config/mpv/mvi/input.conf @@ -7,6 +7,10 @@ SPACE repeatable playlist-next alt+SPACE repeatable playlist-prev +# familiar binds +n playlist-next +p playlist-prev + UP ignore DOWN ignore LEFT repeatable playlist-prev @@ -97,7 +101,7 @@ S screenshot window # Toggle aspect ratio information on and off A cycle-values video-aspect-override "-1" "no" -p script-message force-print-filename +P script-message force-print-filename # ADVANCED: you can define bindings that belong to a "section" (named "image-viewer" here) like so: #alt+SPACE {image-viewer} repeatable playlist-prev diff --git a/.config/mpv/mvi/scripts/mouse_coords.lua b/.config/mpv/mvi/scripts/mouse_coords.lua new file mode 120000 index 0000000..ecd3896 --- /dev/null +++ b/.config/mpv/mvi/scripts/mouse_coords.lua @@ -0,0 +1 @@ +../../scripts/mouse_coords.lua \ No newline at end of file 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) -- cgit 1.4.1