Skip to content

Instantly share code, notes, and snippets.

@tunalad
Last active May 15, 2024 19:18
Show Gist options
  • Save tunalad/d00a8e6ba5e2e2cd16619df0ea8e785d to your computer and use it in GitHub Desktop.
Save tunalad/d00a8e6ba5e2e2cd16619df0ea8e785d to your computer and use it in GitHub Desktop.
In input.conf, put something like this: `B script-message toggle_osc`
--[[
Toggles OSC between "auto" and "always"
https://gist.github.com/tunalad/d00a8e6ba5e2e2cd16619df0ea8e785d
]]--
local osc_visible = false
local function toggle_osc()
osc_visible = not osc_visible
if osc_visible then
mp.commandv("script-message", "osc-visibility", "always")
mp.osd_message("OSC: Always", 2)
else
mp.commandv("script-message", "osc-visibility", "auto")
mp.osd_message("OSC: Auto", 2)
end
end
local function on_key_press()
toggle_osc()
end
mp.add_key_binding(nil, "toggle_osc", on_key_press)
local function observe_osc_visibility(_, value)
if value ~= nil then
osc_visible = (value == "always")
mp.osd_message("OSC: " .. value, 2)
end
end
mp.register_event("file-loaded", function()
mp.observe_property("osc-visibility", "string", observe_osc_visibility)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment