Skip to content

Commit

Permalink
osc.lua: cycle tracks when there's only one
Browse files Browse the repository at this point in the history
When there is 1 audio or sub track, make left click select or unselect
it directly without opening the selector. The script-opt command is
ignored in this case.

Requested by sfan5.
  • Loading branch information
guidocella committed Oct 26, 2024
1 parent 9af491f commit 94c89cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions DOCS/man/osc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ Configurable Options
The following options configure what commands are run when the buttons are
clicked. ``mbtn_mid`` commands are also triggered with ``shift+mbtn_left``.

When there's only one track of a type, left clicks on track buttons always cycle
it instead of using the configured command.

``title_mbtn_left_command=script-binding select/select-playlist; script-message-to osc osc-hide``

``title_mbtn_mid_command=show-text ${filename}``
Expand Down
8 changes: 6 additions & 2 deletions player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,9 @@ 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"] = command_callback(user_opts.audio_track_mbtn_left_command)
ne.eventresponder["mbtn_left_up"] = command_callback(audio_track_count == 1
and "cycle audio"
or 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)
Expand All @@ -1886,7 +1888,9 @@ 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"] = command_callback(user_opts.sub_track_mbtn_left_command)
ne.eventresponder["mbtn_left_up"] = command_callback(audio_track_count == 1
and "cycle sub"
or 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)

Expand Down

0 comments on commit 94c89cd

Please sign in to comment.