mirror of https://github.com/mpv-player/mpv
osc.lua: make mouse bindings customizable
This adds several script-opts to configure what OSC buttons do when clicked. It lets you restore the bindings present before they were changed to call select.lua. The script-opts are listed one per line in the manual to not make that section huge. skip_backward and skip_forward script-opts are omitted to lower the script-opts number because they are only in box layout and undocumented. I'm not sure if it's worth adding script-opts for the wheel on the seekbar. script-opts for the current and remaining time and fullscreen are not added to not add more script messages. Closes #6291 and #11878.
This commit is contained in:
parent
8e327f28b4
commit
a80f535a6d
|
@ -0,0 +1,4 @@
|
|||
change several OSC mouse bindings to select.lua functions
|
||||
add script-opts to configure what OSC buttons do when clicked
|
||||
remove `osc-playlist_osd` script-opt and behave as if it was off by default; `playlist_osd=yes` can be replicated with `osc-playlist_prev_mbtn_left_command=playlist-prev; show-text ${playlist} 3000` and `osc-playlist_next_mbtn_left_command=playlist-next; show-text ${playlist} 3000`
|
||||
remove `osc-chapters_osd` script-opt and behave as if it was off by default; `chapter_osd=yes` can be replicated with `osc-chapter_prev_mbtn_left_command=no-osd add chapter -1; show-text ${chapter-list} 3000` and `osc-chapter_next_mbtn_left_command=no-osd add chapter 1; show-text ${chapter-list} 3000`
|
|
@ -492,6 +492,74 @@ Configurable Options
|
|||
|
||||
Use display fps to calculate the interval between OSC redraws.
|
||||
|
||||
The following options configure what commands are run when the buttons are
|
||||
clicked. ``mbtn_mid`` commands are also triggered with ``shift+mbtn_left``.
|
||||
|
||||
``title_mbtn_left_command=script-binding select/select-playlist; script-message-to osc osc-hide``
|
||||
|
||||
``title_mbtn_mid_command=show-text ${filename}``
|
||||
|
||||
``title_mbtn_right_command=script-binding stats/display-page-5``
|
||||
|
||||
``playlist_prev_mbtn_left_command=playlist-prev; show-text ${playlist} 3000``
|
||||
|
||||
``playlist_prev_mbtn_mid_command=show-text ${playlist} 3000``
|
||||
|
||||
``playlist_prev_mbtn_right_command=script-binding select/select-playlist; script-message-to osc osc-hide``
|
||||
|
||||
``playlist_next_mbtn_left_command=playlist-next; show-text ${playlist} 3000``
|
||||
|
||||
``playlist_next_mbtn_mid_command=show-text ${playlist} 3000``
|
||||
|
||||
``playlist_next_mbtn_right_command=script-binding select/select-playlist; script-message-to osc osc-hide``
|
||||
|
||||
``play_pause_mbtn_left_command=cycle pause``
|
||||
|
||||
``play_pause_mbtn_mid_command=``
|
||||
|
||||
``play_pause_mbtn_right_command=``
|
||||
|
||||
``chapter_prev_mbtn_left_command=no-osd add chapter -1; show-text ${chapter-list} 3000``
|
||||
|
||||
``chapter_prev_mbtn_mid_command=show-text ${chapter-list} 3000``
|
||||
|
||||
``chapter_prev_mbtn_right_command=script-binding select/select-chapter; script-message-to osc osc-hide``
|
||||
|
||||
``chapter_next_mbtn_left_command=no-osd add chapter 1; show-text ${chapter-list} 3000``
|
||||
|
||||
``chapter_next_mbtn_mid_command=show-text ${chapter-list} 3000``
|
||||
|
||||
``chapter_next_mbtn_right_command=script-binding select/select-chapter; script-message-to osc osc-hide``
|
||||
|
||||
``audio_track_mbtn_left_command=script-binding select/select-aid; script-message-to osc osc-hide``
|
||||
|
||||
``audio_track_mbtn_mid_command=show-text ${track-list/audio} 2000``
|
||||
|
||||
``audio_track_mbtn_right_command=show-text ${track-list/audio} 2000``
|
||||
|
||||
``audio_track_wheel_down_command=cycle audio``
|
||||
|
||||
``audio_track_wheel_up_command=cycle audio down``
|
||||
|
||||
``sub_track_mbtn_left_command=script-binding select/select-sid; script-message-to osc osc-hide``
|
||||
|
||||
``sub_track_mbtn_mid_command=show-text ${track-list/sub} 2000``
|
||||
|
||||
``sub_track_mbtn_right_command=show-text ${track-list/sub} 2000``
|
||||
|
||||
``sub_track_wheel_down_command=cycle sub``
|
||||
|
||||
``sub_track_wheel_up_command=cycle sub down``
|
||||
|
||||
``volume_mbtn_left_command=no-osd cycle mute``
|
||||
|
||||
``volume_mbtn_mid_command=``
|
||||
|
||||
``volume_mbtn_right_command=script-binding select/select-audio-device; script-message-to osc osc-hide``
|
||||
|
||||
``volume_wheel_down_command=add volume -5``
|
||||
|
||||
``volume_wheel_up_command=add volume 5``
|
||||
|
||||
Script Commands
|
||||
~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -50,8 +50,6 @@ local user_opts = {
|
|||
windowcontrols_title = "${media-title}", -- same as title but for windowcontrols
|
||||
greenandgrumpy = false, -- disable santa hat
|
||||
livemarkers = true, -- update seekbar chapter markers on duration change
|
||||
chapters_osd = false, -- whether to show chapters OSD on next/prev
|
||||
playlist_osd = false, -- whether to show playlist OSD on next/prev
|
||||
chapter_fmt = "Chapter: %s", -- chapter print format for seekbar-hover. "no" to disable
|
||||
unicodeminus = false, -- whether to use the Unicode minus sign character
|
||||
|
||||
|
@ -67,8 +65,53 @@ local user_opts = {
|
|||
|
||||
time_pos_outline_color = "#000000", -- color of the border timecodes in slimbox and TimePosBar
|
||||
|
||||
tick_delay = 1 / 60, -- minimum interval between OSC redraws in seconds
|
||||
tick_delay_follow_display_fps = false -- use display fps as the minimum interval
|
||||
tick_delay = 1 / 60, -- minimum interval between OSC redraws in seconds
|
||||
tick_delay_follow_display_fps = false, -- use display fps as the minimum interval
|
||||
|
||||
-- luacheck: push ignore
|
||||
-- luacheck: max line length
|
||||
title_mbtn_left_command = "script-binding select/select-playlist; script-message-to osc osc-hide",
|
||||
title_mbtn_mid_command = "show-text ${filename}",
|
||||
title_mbtn_right_command = "script-binding stats/display-page-5",
|
||||
|
||||
playlist_prev_mbtn_left_command = "playlist-prev",
|
||||
playlist_prev_mbtn_mid_command = "show-text ${playlist} 3000",
|
||||
playlist_prev_mbtn_right_command = "show-text ${playlist} 3000",
|
||||
|
||||
playlist_next_mbtn_left_command = "playlist-next",
|
||||
playlist_next_mbtn_mid_command = "show-text ${playlist} 3000",
|
||||
playlist_next_mbtn_right_command = "show-text ${playlist} 3000",
|
||||
|
||||
play_pause_mbtn_left_command = "cycle pause",
|
||||
play_pause_mbtn_mid_command = "",
|
||||
play_pause_mbtn_right_command = "",
|
||||
|
||||
chapter_prev_mbtn_left_command = "add chapter -1",
|
||||
chapter_prev_mbtn_mid_command = "show-text ${chapter-list} 3000",
|
||||
chapter_prev_mbtn_right_command = "script-binding select/select-chapter; script-message-to osc osc-hide",
|
||||
|
||||
chapter_next_mbtn_left_command = "add chapter 1",
|
||||
chapter_next_mbtn_mid_command = "show-text ${chapter-list} 3000",
|
||||
chapter_next_mbtn_right_command = "script-binding select/select-chapter; script-message-to osc osc-hide",
|
||||
|
||||
audio_track_mbtn_left_command = "script-binding select/select-aid; script-message-to osc osc-hide",
|
||||
audio_track_mbtn_mid_command = "show-text ${track-list/audio} 2000",
|
||||
audio_track_mbtn_right_command = "show-text ${track-list/audio} 2000",
|
||||
audio_track_wheel_down_command = "cycle audio",
|
||||
audio_track_wheel_up_command = "cycle audio down",
|
||||
|
||||
sub_track_mbtn_left_command = "script-binding select/select-sid; script-message-to osc osc-hide",
|
||||
sub_track_mbtn_mid_command = "show-text ${track-list/sub} 2000",
|
||||
sub_track_mbtn_right_command = "show-text ${track-list/sub} 2000",
|
||||
sub_track_wheel_down_command = "cycle sub",
|
||||
sub_track_wheel_up_command = "cycle sub down",
|
||||
|
||||
volume_mbtn_left_command = "no-osd cycle mute",
|
||||
volume_mbtn_mid_command = "",
|
||||
volume_mbtn_right_command = "script-binding select/select-audio-device; script-message-to osc osc-hide",
|
||||
volume_wheel_down_command = "add volume -5",
|
||||
volume_wheel_up_command = "add volume 5",
|
||||
-- luacheck: pop
|
||||
}
|
||||
|
||||
local osc_param = { -- calculated by osc_init()
|
||||
|
@ -1644,6 +1687,14 @@ layouts["topbar"] = function()
|
|||
end
|
||||
|
||||
|
||||
local function command_callback(command)
|
||||
if command ~= "" then
|
||||
return function ()
|
||||
mp.command(command)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function osc_init()
|
||||
msg.debug("osc_init")
|
||||
|
||||
|
@ -1702,15 +1753,9 @@ local function osc_init()
|
|||
return title ~= "" and mp.command_native({"escape-ass", title}) or "mpv"
|
||||
end
|
||||
|
||||
ne.eventresponder["mbtn_left_up"] = function ()
|
||||
mp.command("script-binding select/select-playlist; script-message-to osc osc-hide")
|
||||
end
|
||||
ne.eventresponder["shift+mbtn_left_up"] = function ()
|
||||
mp.command("show-text ${filename}")
|
||||
end
|
||||
ne.eventresponder["mbtn_right_up"] = function ()
|
||||
mp.command("script-binding stats/display-page-5")
|
||||
end
|
||||
ne.eventresponder["mbtn_left_up"] = command_callback(user_opts.title_mbtn_left_command)
|
||||
ne.eventresponder["shift+mbtn_left_up"] = command_callback(user_opts.title_mbtn_mid_command)
|
||||
ne.eventresponder["mbtn_right_up"] = command_callback(user_opts.title_mbtn_right_command)
|
||||
|
||||
-- playlist buttons
|
||||
|
||||
|
@ -1719,34 +1764,24 @@ local function osc_init()
|
|||
|
||||
ne.content = "\238\132\144"
|
||||
ne.enabled = (pl_pos > 1) or (loop ~= "no")
|
||||
ne.eventresponder["mbtn_left_up"] =
|
||||
function ()
|
||||
mp.commandv("playlist-prev", "weak")
|
||||
if user_opts.playlist_osd then
|
||||
mp.command("show-text ${playlist} 3000")
|
||||
end
|
||||
end
|
||||
ne.eventresponder["shift+mbtn_left_up"] =
|
||||
function () mp.command("show-text ${playlist} 3000") end
|
||||
ne.eventresponder["mbtn_right_up"] =
|
||||
function () mp.command("show-text ${playlist} 3000") end
|
||||
ne.eventresponder["mbtn_left_up"] = command_callback(
|
||||
user_opts.playlist_prev_mbtn_left_command)
|
||||
ne.eventresponder["shift+mbtn_left_up"] = command_callback(
|
||||
user_opts.playlist_prev_mbtn_mid_command)
|
||||
ne.eventresponder["mbtn_right_up"] = command_callback(
|
||||
user_opts.playlist_prev_mbtn_right_command)
|
||||
|
||||
--next
|
||||
ne = new_element("playlist_next", "button")
|
||||
|
||||
ne.content = "\238\132\129"
|
||||
ne.enabled = (have_pl and (pl_pos < pl_count)) or (loop ~= "no")
|
||||
ne.eventresponder["mbtn_left_up"] =
|
||||
function ()
|
||||
mp.commandv("playlist-next", "weak")
|
||||
if user_opts.playlist_osd then
|
||||
mp.command("show-text ${playlist} 3000")
|
||||
end
|
||||
end
|
||||
ne.eventresponder["shift+mbtn_left_up"] =
|
||||
function () mp.command("show-text ${playlist} 3000") end
|
||||
ne.eventresponder["mbtn_right_up"] =
|
||||
function () mp.command("show-text ${playlist} 3000") end
|
||||
ne.eventresponder["mbtn_left_up"] = command_callback(
|
||||
user_opts.playlist_next_mbtn_left_command)
|
||||
ne.eventresponder["shift+mbtn_left_up"] = command_callback(
|
||||
user_opts.playlist_next_mbtn_mid_command)
|
||||
ne.eventresponder["mbtn_right_up"] = command_callback(
|
||||
user_opts.playlist_next_mbtn_right_command)
|
||||
|
||||
|
||||
-- big buttons
|
||||
|
@ -1765,8 +1800,11 @@ local function osc_init()
|
|||
return ("\238\128\130")
|
||||
end
|
||||
end
|
||||
ne.eventresponder["mbtn_left_up"] =
|
||||
function () mp.commandv("cycle", "pause") end
|
||||
ne.eventresponder["mbtn_left_up"] = command_callback(user_opts.play_pause_mbtn_left_command)
|
||||
ne.eventresponder["shift+mbtn_left_up"] = command_callback(
|
||||
user_opts.play_pause_mbtn_mid_command)
|
||||
ne.eventresponder["mbtn_right_up"] = command_callback(
|
||||
user_opts.play_pause_mbtn_right_command)
|
||||
|
||||
--skip_backward
|
||||
ne = new_element("skip_backward", "button")
|
||||
|
@ -1797,36 +1835,21 @@ local function osc_init()
|
|||
|
||||
ne.enabled = have_ch
|
||||
ne.content = "\238\132\132"
|
||||
ne.eventresponder["mbtn_left_up"] =
|
||||
function ()
|
||||
mp.commandv("add", "chapter", -1)
|
||||
if user_opts.chapters_osd then
|
||||
mp.command("show-text ${chapter-list} 3000")
|
||||
end
|
||||
end
|
||||
ne.eventresponder["shift+mbtn_left_up"] =
|
||||
function () mp.command("show-text ${chapter-list} 3000") end
|
||||
ne.eventresponder["mbtn_right_up"] = function ()
|
||||
mp.command("script-binding select/select-chapter; script-message-to osc osc-hide")
|
||||
end
|
||||
ne.eventresponder["mbtn_left_up"] = command_callback(user_opts.chapter_prev_mbtn_left_command)
|
||||
ne.eventresponder["shift+mbtn_left_up"] = command_callback(
|
||||
user_opts.chapter_prev_mbtn_mid_command)
|
||||
ne.eventresponder["mbtn_right_up"] = command_callback(
|
||||
user_opts.chapter_prev_mbtn_right_command)
|
||||
|
||||
--chapter_next
|
||||
ne = new_element("chapter_next", "button")
|
||||
|
||||
ne.enabled = have_ch
|
||||
ne.content = "\238\132\133"
|
||||
ne.eventresponder["mbtn_left_up"] =
|
||||
function ()
|
||||
mp.commandv("add", "chapter", 1)
|
||||
if user_opts.chapters_osd then
|
||||
mp.command("show-text ${chapter-list} 3000")
|
||||
end
|
||||
end
|
||||
ne.eventresponder["shift+mbtn_left_up"] =
|
||||
function () mp.command("show-text ${chapter-list} 3000") end
|
||||
ne.eventresponder["mbtn_right_up"] = function ()
|
||||
mp.command("script-binding select/select-chapter; script-message-to osc osc-hide")
|
||||
end
|
||||
ne.eventresponder["mbtn_left_up"] = command_callback(user_opts.chapter_next_mbtn_left_command)
|
||||
ne.eventresponder["shift+mbtn_left_up"] = command_callback(
|
||||
user_opts.chapter_next_mbtn_mid_command)
|
||||
ne.eventresponder["mbtn_right_up"] = command_callback(user_opts.chapter_next_mbtn_right_command)
|
||||
|
||||
--
|
||||
update_tracklist()
|
||||
|
@ -1839,19 +1862,16 @@ local function osc_init()
|
|||
return ("\238\132\134" .. osc_styles.smallButtonsLlabel .. " " ..
|
||||
(mp.get_property_native("aid") or "-") .. "/" .. audio_track_count)
|
||||
end
|
||||
ne.eventresponder["mbtn_left_up"] = function ()
|
||||
mp.command("script-binding select/select-aid; script-message-to osc osc-hide")
|
||||
end
|
||||
ne.eventresponder["shift+mbtn_left_up"] =
|
||||
function () mp.command("show-text ${track-list/audio} 2000") end
|
||||
ne.eventresponder["shift+mbtn_right_up"] =
|
||||
function () mp.command("show-text ${track-list/sub} 2000") end
|
||||
ne.eventresponder["mbtn_left_up"] = command_callback(user_opts.audio_track_mbtn_left_command)
|
||||
ne.eventresponder["shift+mbtn_left_up"] = command_callback(
|
||||
user_opts.audio_track_mbtn_mid_command)
|
||||
ne.eventresponder["mbtn_right_up"] = command_callback(user_opts.audio_track_mbtn_right_command)
|
||||
|
||||
if user_opts.scrollcontrols then
|
||||
ne.eventresponder["wheel_down_press"] =
|
||||
function () mp.command("cycle audio") end
|
||||
ne.eventresponder["wheel_up_press"] =
|
||||
function () mp.command("cycle audio down") end
|
||||
ne.eventresponder["wheel_down_press"] = command_callback(
|
||||
user_opts.audio_track_wheel_down_command)
|
||||
ne.eventresponder["wheel_up_press"] = command_callback(
|
||||
user_opts.audio_track_wheel_up_command)
|
||||
end
|
||||
|
||||
--sub_track
|
||||
|
@ -1862,19 +1882,14 @@ local function osc_init()
|
|||
return ("\238\132\135" .. osc_styles.smallButtonsLlabel .. " " ..
|
||||
(mp.get_property_native("sid") or "-") .. "/" .. sub_track_count)
|
||||
end
|
||||
ne.eventresponder["mbtn_left_up"] = function ()
|
||||
mp.command("script-binding select/select-sid; script-message-to osc osc-hide")
|
||||
end
|
||||
ne.eventresponder["shift+mbtn_left_up"] =
|
||||
function () mp.command("show-text ${track-list/sub} 2000") end
|
||||
ne.eventresponder["shift+mbtn_right_up"] =
|
||||
function () mp.command("show-text ${track-list/sub} 2000") end
|
||||
ne.eventresponder["mbtn_left_up"] = command_callback(user_opts.sub_track_mbtn_left_command)
|
||||
ne.eventresponder["shift+mbtn_left_up"] = command_callback(user_opts.sub_track_mbtn_mid_command)
|
||||
ne.eventresponder["mbtn_right_up"] = command_callback(user_opts.sub_track_mbtn_right_command)
|
||||
|
||||
if user_opts.scrollcontrols then
|
||||
ne.eventresponder["wheel_down_press"] =
|
||||
function () mp.command("cycle sub") end
|
||||
ne.eventresponder["wheel_up_press"] =
|
||||
function () mp.command("cycle sub down") end
|
||||
ne.eventresponder["wheel_down_press"] = command_callback(
|
||||
user_opts.sub_track_wheel_down_command)
|
||||
ne.eventresponder["wheel_up_press"] = command_callback(user_opts.sub_track_wheel_up_command)
|
||||
end
|
||||
|
||||
--tog_fs
|
||||
|
@ -2076,17 +2091,14 @@ local function osc_init()
|
|||
return volicon[math.min(4,math.ceil(volume / (100/3)))]
|
||||
end
|
||||
end
|
||||
ne.eventresponder["mbtn_left_up"] =
|
||||
function () mp.commandv("cycle", "mute") end
|
||||
ne.eventresponder["mbtn_right_up"] = function ()
|
||||
mp.command("script-binding select/select-audio-device; script-message-to osc osc-hide")
|
||||
end
|
||||
ne.eventresponder["mbtn_left_up"] = command_callback(user_opts.volume_mbtn_left_command)
|
||||
ne.eventresponder["shift+mbtn_left_up"] = command_callback(user_opts.volume_mbtn_mid_command)
|
||||
ne.eventresponder["mbtn_right_up"] = command_callback(user_opts.volume_mbtn_right_command)
|
||||
|
||||
if user_opts.scrollcontrols then
|
||||
ne.eventresponder["wheel_up_press"] =
|
||||
function () mp.commandv("osd-auto", "add", "volume", 5) end
|
||||
ne.eventresponder["wheel_down_press"] =
|
||||
function () mp.commandv("osd-auto", "add", "volume", -5) end
|
||||
ne.eventresponder["wheel_down_press"] = command_callback(
|
||||
user_opts.volume_wheel_down_command)
|
||||
ne.eventresponder["wheel_up_press"] = command_callback(user_opts.volume_wheel_up_command)
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue