sane-cast: integrate with mpv

This commit is contained in:
2024-04-23 07:49:05 +00:00
parent e33b7d7701
commit 152a5d4c92
4 changed files with 14 additions and 13 deletions

View File

@@ -760,6 +760,8 @@ in
rustc = {};
sane-cast = {}; #< TODO: sandbox this the same way i sandbox go2tv
sane-die-with-parent.sandbox.enable = false; #< it's a launcher; can't sandbox
sane-open-desktop.sandbox.enable = false; #< trivial script, and all our deps are sandboxed

View File

@@ -185,6 +185,7 @@ in
suggestedPrograms = [
"blast-to-default"
"go2tv"
"sane-cast"
"sane-die-with-parent"
"xdg-terminal-exec"
];

View File

@@ -34,6 +34,5 @@ alt+i script-binding uosc/keybinds #! Utils > Key bindings
O script-binding uosc/show-in-directory #! Utils > Show in directory
# script-binding uosc/open-config-directory #! Utils > Open config directory
ctrl+r script-binding sane_cast/blast #! Audiocast
ctrl+t script-binding sane_cast/go2tv-video #! Cast
# script-binding sane_cast/go2tv-stream #! Cast (...) > Stream
ctrl+t script-binding sane_cast/sane-cast #! Cast
# script-binding sane_cast/go2tv-gui #! Cast (...) > GUI

View File

@@ -18,17 +18,17 @@ function subprocess(in_terminal, args)
})
end
function invoke_go2tv(in_terminal, args)
function invoke_paused(in_terminal, args)
mp.commandv("set", "pause", "yes")
subprocess(in_terminal, { "go2tv", table.unpack(args) })
for k, v in ipairs(args) do
if v == "@FILE@" then
args[k] = mp.get_property("stream-open-filename")
end
end
subprocess(in_terminal, args)
end
function invoke_go2tv_on_open_file(mode)
msg.trace("invoke_go2tv_on_open_file")
local path = mp.get_property("stream-open-filename")
msg.trace("path:", path)
invoke_go2tv(true, { mode, path })
end
-- invoke blast in a way where it dies when we die, because:
-- 1. when mpv exits, it `SIGKILL`s this toplevel subprocess.
@@ -36,8 +36,7 @@ end
-- 3. bwrap does not pass SIGKILL or SIGTERM to its child.
-- 4. hence, to properly kill blast, we have to kill all the descendants.
mp.add_key_binding(nil, "blast", function() subprocess(false, { "sane-die-with-parent", "--descendants", "--use-pgroup", "--catch-sigkill", "blast-to-default" }) end)
mp.add_key_binding(nil, "go2tv-gui", function() invoke_go2tv(false, {}) end)
mp.add_key_binding(nil, "go2tv-video", function() invoke_go2tv_on_open_file("-v") end)
mp.add_key_binding(nil, "go2tv-stream", function() invoke_go2tv_on_open_file("-s") end)
mp.add_key_binding(nil, "go2tv-gui", function() invoke_paused(false, { "go2tv" }) end)
mp.add_key_binding(nil, "sane-cast", function() invoke_paused(true, { "sane-cast", "--verbose", "@FILE@" }) end)
msg.trace("load: complete")