From 4e34cbf9673aeaba252e01df554a0d204e83c5e2 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 8 Apr 2026 13:26:13 +0900 Subject: * MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated-commit-by: dots Signed-off-by: Robert Günzler --- .config/mpv/scripts/openuri.lua | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .config/mpv/scripts/openuri.lua (limited to '.config/mpv/scripts/openuri.lua') diff --git a/.config/mpv/scripts/openuri.lua b/.config/mpv/scripts/openuri.lua new file mode 100644 index 0000000..61b20e5 --- /dev/null +++ b/.config/mpv/scripts/openuri.lua @@ -0,0 +1,42 @@ +mp = require("mp") +format_json = require("mp.utils").format_json + +function open_uri() + local json = format_json({ + type = "open-uri", + title = "https://mpv.io", + items = { + { + title = "Enter a network url", + align = "left", + value = "ignore", + muted = true, + selectable = false + } + }, + on_search = { "script-message-to", mp.get_script_name(), "openuri-cb" }, + palette = true, + search_style = "palette", + search_debounce = "submit" + }) or "{}" + mp.commandv("script-message-to", "uosc", "open-menu", json) +end + +mp.register_script_message("openuri-cb", function(path) + mp.commandv("script-message-to", "uosc", "close-menu", "openuri") + mp.commandv("loadfile", path, "append-play") +end) + +mp.add_key_binding("ctrl+o", "openuri", open_uri) + +mp.add_key_binding("ctrl+shift+o", "pasteuri", function() + local r = mp.command_native({ + name = "subprocess", + playback_only = false, + capture_stdout = true, + args = { "wl-paste" }, + }) + if r.status == 0 then + mp.commandv("script-message-to", mp.get_script_name(), "openuri-cb", r.stdout) + end +end) -- cgit 1.4.1