po5 / mpv_sponsorblock

mpv script to skip sponsored segments of YouTube videos
GNU General Public License v3.0
549 stars 29 forks source link

How to disable all keybindings? #48

Closed ghost closed 2 years ago

ghost commented 2 years ago

Default key bindings:

  • g to set segment boundaries
  • G (shift+g) to submit a segment
  • h to upvote the last segment
  • H (shift+h) to downvote the last segment

These can be remapped with the following script bindings: sponsorblock/set_segment, sponsorblock/submit_segment, sponsorblock/upvote_segment, sponsorblock/downvote_segment

Can the mappings be disabled like keys in the mpv's input.conf?

WHEEL_UP ignore
WHEEL_DOWN ignore
ghost commented 2 years ago

https://github.com/po5/mpv_sponsorblock/blob/master/sponsorblock.lua#L560-L563 ?

ghost commented 2 years ago

https://github.com/po5/mpv_sponsorblock/blob/master/sponsorblock.lua#L560-L563

I suppose that remapping is officially supported and there's no need for further implementations.

selurvedu commented 3 months ago

I suppose that remapping is officially supported and there's no need for further implementations.

There's no easy way to restore the default mpv keybindings for g G h H without redefining them again in input.conf or editing sponsorblock.lua. I had to replace them with nil like this:

--- sponsorblock.lua
+++ sponsorblock.lua
@@ -558,10 +558,10 @@
 end

 mp.register_event("file-loaded", file_loaded)
-mp.add_key_binding("g", "set_segment", set_segment)
-mp.add_key_binding("G", "submit_segment", submit_segment)
-mp.add_key_binding("h", "upvote_segment", function() return vote("1") end)
-mp.add_key_binding("H", "downvote_segment", function() return vote("0") end)
+mp.add_key_binding(nil, "set_segment", set_segment)
+mp.add_key_binding(nil, "submit_segment", submit_segment)
+mp.add_key_binding(nil, "upvote_segment", function() return vote("1") end)
+mp.add_key_binding(nil, "downvote_segment", function() return vote("0") end)
 -- Bindings below are for backwards compatibility and could be removed at any time
 mp.add_key_binding(nil, "sponsorblock_set_segment", set_segment)
 mp.add_key_binding(nil, "sponsorblock_submit_segment", submit_segment)
po5 commented 3 months ago

--input-default-bindings=no

selurvedu commented 3 months ago

--input-default-bindings=no

That kills all default mpv keybindings. This is not what most users want.

po5 commented 3 months ago

Complain on the mpv bug tracker to add an option to disable only script bindings.

selurvedu commented 3 months ago

I don't want to disable all script bindings, I want to disable the bindings for one script only, and maybe not even all of them.

There is no point in complaining about that on the mpv bugtracker as they will most likely say the plugin has to handle that, not mpv.

The only thing I could ask for there could be a function similar to mp.remove_key_binding() that would only remove the binding to a key (e.g. "g"), not the definition of an bindable action itself (e.g. "set_segment"), so that the user would be able to unset some undesirable bindings (and maybe remap them to other keys, i.e., this is impossible with regular mp.remove_key_binding) without losing the binding that the key was set to originally (e.g. loaded from default mpv keybindings or set by another plugin that got loaded earlier).