Skip to content

Seme4eg/mpv-scripts

Repository files navigation

MPV scripts

Table of contents

M-x

demo

A menu that shows all commands you have available, key bindings and commends (if present) and from which you can call any of those commands.

Setup:

  • copy M-x.lua to your ~~/scripts
  • copy ./script-modules/extended-menu.lua to your ~~/script-modules
  • copy ./script-opts/M_x.conf to your ~~/scripts-opts

Keybidings you can see in extended menu keybindings section.

Note: if you are using my leader script, you will see your leader bindings in M-x menu as well.

M-x-rofi

demo

Essentially same thing as the M-x menu above, but instead of using extended-menu module uses external rofi to display and search through commands.

Setup:

  • copy M-x-rofi.lua to your ~~/scripts
  • copy ./script-opts/M_x_rofi.conf to your ~~/scripts-opts

Note: if you are using my leader script, you will see your leader bindings in M-x menu as well.

Leader

demo

Adds leader key to your mpv. With prefixes and which-key functionality. Allows for ‘mnemonic’ command calling.

It won’t redefine existing bidings (at least i didn’t find a way to do it for now), but it will add leader bindings on top of current ones, which will allow you to freely redefine previous key bindings to any other command. For instance if you had seek command on l key and you bound it to <leader> n then u can bind any other command to l and you will still have <leader> n bound to seek.

NOTE: For script commands to appear in leader key bindings (after you set those up in script file) they must be initially set to some key, which is usually not a problem since most (if not all) scripts bind themselfes to some default key.

Setup:

  • copy leader.lua to your ~~/scripts
  • copy ./script-modules/leader.lua to your ~~/script-modules
  • copy ./script-opts/leader.conf to your ~~/script-opts

Binding table format

Example can be found in the script file itself.

{'key', 'name', 'description', [innerBindings]}

Key

Any key you desire

Name

Can be one of:

full command name
means it is not a script-defined command, will look like "add contrast 1". Full list of all commands can be found using my M-x script.
prefix
literaly 'prefix' string, which will tell the script that there are following bindings after this one.
script command name
To set binding to a script command look for this command name, which is passed as 2nd argument to mp.add_key_binding or mp.add_forced_key_binding and usually can be found in its script file. This field must be unique. Examples:
-- here command name is "M-x"
mp.add_key_binding(opts.toggle_menu_binding, "M-x", function()
                     mx_menu:init(data)
end)

-- here command name is "chapters-menu"
mp.add_key_binding(opts.toggle_menu_binding, "chapters-menu", function()
                     chapter_menu:init(chapter)
end)

Description

String that describes what the command that is bound to this binding does. In case name field is 'prefix' for your convenience i’d suggest setting 1-3 word description. For example for a prefix audio description, subtitles description for s prefix etc.

Inner bindings

Only being used with keys that are prefixes. Includes keys following that prefix key, consista of same format tables - {‘key’, ‘name’, ‘description’, [innerBindings]}. Key field within this table is being concatenated with all parent prefixes.

{'s', 'prefix', 'subtitles', {'a', 'prefix', ... {'+', 'increase-font', ...}}} will result in sa+ keybinding for increase-font command.

Passing bindings table to script-module

Pass it to set_leader_bindings func, which can be found in the end of ~~/scripts/leader.lua

Todos [1/4]

sort bindings by key, to show them in which-key in alphabetical order

Move my bindings table somewhere else

Move my keybinding object definition out of the script file so the user just has an example somewhere. And also current realisation will cause conflicts when pulling from master since everyone will have his own bindings object.

Upon init set all leader bindings to M-x and merge it there

move recently called commands to top of M-x menu list

Shaders-rofi

Set shaders from your shaders folder using rofi selection.

Setup:

  • copy shaders-rofi.lua to your ~~/scripts

Ctrl+s - default keybinding. Change it via input.conf:

Ctrl+t script-binding shaders-rofi

This script assumes shaders are under ~~/shaders/. Make an issue/pull request if redefining shaders dir is a common case.

Chapter list

No demo here since it has basically same functionality as M-x but instead of commands you choose chapters of current video (if any). Shares same script-module with M-x.

Setup:

  • copy chapter_list.lua to your ~~/scripts
  • copy ./script-modules/extended-menu.lua to your ~~/script-modules
  • copy ./script-opts/chapter_list.conf to your ~~/script-opts

Keybindings you can see in extended menu keybindings section.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages