Skip to content

Commit 1f00256

Browse files
committed
menu.conf: add this file
Add a default context menu definition in etc/menu.conf. It will be used to populate the context menu. The format is meant to be easily readable with just tabs as separators and submenus denoted by indentation. It avoids complicating the builtin input.conf like similar scripts do. By not defining the shortcut keys in the builtin input.conf, menu entries won't be associated to wrong shortcuts when the user's input.conf changes key bindings without redefining the menu. Note that external scripts don't have this issue. I used 3+ spaces as separators at first but then realized that since we have Windows users tabs will look better in editors with proportional fonts like notepad, though it still won't be perfectly aligned depending on the font. But I am still not sure what is better. On a curious note, etc/menu.conf already existed in the past as mplayer used to have a menu. git log -p etc/menu.conf will show commits from 2002 to 2010.
1 parent a8821da commit 1f00256

File tree

5 files changed

+173
-7
lines changed

5 files changed

+173
-7
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ indent_style = unset
2121
indent_size = unset
2222
max_line_length = unset
2323
trim_trailing_whitespace = unset
24+
25+
[menu.conf]
26+
indent_style = tab

DOCS/man/context_menu.rst

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
CONTEXT MENU SCRIPT
22
===================
33

4-
This script provides a context menu for platforms without integration with a
5-
native context menu. On these platforms, it can be disabled entirely using the
6-
``--load-context-menu=no`` option. On platforms where the integration is
7-
implemented, it is already disabled by default.
4+
The context menu is a menu that pops up on the video window. By default, it is
5+
bound to right click.
6+
7+
menu.conf
8+
---------
9+
10+
You can define your own menu in ``~~/menu.conf`` (see `FILES`_). It is
11+
recommended to use the default ``menu.conf`` from
12+
https://github.com/mpv-player/mpv/blob/master/etc/menu.conf as an example to get
13+
started.
14+
15+
Each line of ``menu.conf`` is a menu entry with fields separated by 1 or more
16+
tabs. The first field is the text shown in the menu. The second field is usually
17+
the command that is run when that entry is selected. Fields from the third
18+
onwards can specify ``checked=``, ``disabled=`` and ``hidden=`` states in the
19+
same way as `Conditional auto profiles`_.
20+
21+
When there is only one field, or the second field specifies a state, it is
22+
interpreted as the title of an entry associated with a submenu. Fields below
23+
indented with leading whitespace are added to this submenu. Nested submenu items
24+
are defined by adding more leading whitespace than the parent menu entry.
25+
26+
Empty lines are interpreted as separators.
27+
28+
The second field can also be one of the following tokens to make that entry a
29+
submenu with the relative items: ``$playlist``, ``$video-tracks``,
30+
``$audio-tracks``, ``$sub-tracks``, ``$secondary-sub-tracks``, ``$chapters``,
31+
``$editions``, ``$audio-devices``. These menus are automatically disabled when
32+
empty.
833

934
Script messages
1035
---------------

DOCS/tech-overview.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,9 @@ sub/:
272272
sd_ass.c's internal state.
273273

274274
etc/:
275-
The files input.conf and builtin.conf are actually integrated into the mpv
276-
binary by the build system. They contain the default configs and keybindings.
275+
The files input.conf, builtin.conf and menu.conf are actually integrated
276+
into the mpv binary by the build system. They contain the default configs
277+
and keybindings.
277278

278279
Best practices and Concepts within mpv
279280
======================================

etc/menu.conf

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
Play cycle pause hidden=not pause and not idle_active disabled=idle_active
2+
Pause cycle pause hidden=idle_active or pause
3+
Stop stop hidden=idle ~= true disabled=idle_active
4+
5+
Open
6+
Clipboard loadfile ${clipboard/text} append-play; show-text '+ ${clipboard/text}'
7+
History script-binding select/select-watch-history
8+
Watch later script-binding select/select-watch-later
9+
Playlist $playlist disabled=playlist_count < 2
10+
11+
Video
12+
Track $video-tracks
13+
14+
Fill no-osd cycle-values panscan 0 1; no-osd set video-unscaled no; no-osd set video-zoom 0 checked=panscan == 1
15+
Unscaled no-osd cycle-values video-unscaled yes no; no-osd set video-zoom 0; no-osd set panscan 0 checked=video_unscaled
16+
Zoom
17+
50% set video-zoom -1 checked=video_zoom == -1
18+
100% set video-zoom 0 checked=video_zoom == 0
19+
200% set video-zoom 1 checked=video_zoom == 1
20+
Aspect ratio
21+
16:9 set video-aspect-override 16:9 checked=math.abs(video_aspect_override - 1.7) < 0.1
22+
4:3 set video-aspect-override 4:3 checked=math.abs(video_aspect_override - 1.3) < 0.1
23+
2.35:1 set video-aspect-override 2.35:1 checked=video_aspect_override == 2.35
24+
Default set video-aspect-override no checked=video_aspect_override == -2
25+
Center no-osd set video-pan-x 0; no-osd set video-pan-y 0; no-osd set video-align-x 0; no-osd set video-align-y 0 disabled=video_pan_x == 0 and video_pan_y == 0 and video_align_x == 0 and video_align_y == 0
26+
27+
Rotate clockwise cycle-values video-rotate 90 180 270 0
28+
Rotate counterclockwise cycle-values video-rotate 270 180 90 0
29+
30+
Deband cycle deband checked=deband
31+
Deinterlace cycle deinterlace checked=deinterlace_active
32+
33+
Screenshot screenshot disabled=not p["current-tracks/video"]
34+
Screenshot without subtitles screenshot video disabled=not p["current-tracks/video"]
35+
Audio
36+
Track $audio-tracks
37+
Devices $audio-devices
38+
Channels
39+
Auto set audio-channels auto-safe checked=audio_channels == "auto-safe"
40+
Stereo set audio-channels stereo checked=audio_channels == "stereo"
41+
Mono set audio-channels mono checked=audio_channels == "mono"
42+
43+
Increase volume add volume 2
44+
Decrease volume add volume -2
45+
Mute cycle mute checked=mute
46+
47+
Increase delay add audio-delay 0.1
48+
Decrease delay add audio-delay -0.1
49+
Subtitle
50+
Track $sub-tracks
51+
Visible cycle sub-visibility checked=sub_visibility
52+
53+
Increase delay add sub-delay 0.1
54+
Decrease delay add sub-delay -0.1
55+
56+
Scale up add sub-scale 0.1
57+
Scale down add sub-scale -0.1
58+
59+
Lines script-binding select/select-subtitle-line disabled=not sid or p["current-tracks/sub/codec"] == "dvd_subtitle" or p["current-tracks/sub/codec"] == "hdmv_pgs_subtitle"
60+
Secondary subtitle
61+
Track $secondary-sub-tracks
62+
Visible cycle secondary-sub-visibility checked=secondary_sub_visibility
63+
64+
Increase delay add secondary-sub-delay 0.1
65+
Decrease delay add secondary-sub-delay -0.1
66+
67+
Playback
68+
Display duration hidden=not p["current-tracks/video/image"] or p["current-tracks/audio"]
69+
1 second set image-display-duration 1 checked=image_display_duration == 1
70+
2 seconds set image-display-duration 2 checked=image_display_duration == 2
71+
5 seconds set image-display-duration 5 checked=image_display_duration == 5
72+
10 seconds set image-display-duration 10 checked=image_display_duration == 10
73+
Infinite set image-display-duration inf checked=image_display_duration == math.huge
74+
Speed hidden=p["current-tracks/video/image"] and not p["current-tracks/audio"]
75+
25% set speed 0.25 checked=speed == 0.25
76+
50% set speed 0.50 checked=speed == 0.50
77+
75% set speed 0.75 checked=speed == 0.75
78+
100% set speed 1 checked=speed == 1
79+
125% set speed 1.25 checked=speed == 1.25
80+
150% set speed 1.50 checked=speed == 1.50
81+
175% set speed 1.75 checked=speed == 1.75
82+
200% set speed 2 checked=speed == 2
83+
400% set speed 4 checked=speed == 4
84+
800% set speed 8 checked=speed == 8
85+
86+
Seek 10 seconds forward seek 10 hidden=p["current-tracks/video/image"] and not p["current-tracks/audio"]
87+
Seek 10 seconds backward seek -10 hidden=p["current-tracks/video/image"] and not p["current-tracks/audio"]
88+
Seek 10 minutes forward seek 600 hidden=p["current-tracks/video/image"] and not p["current-tracks/audio"]
89+
Seek 10 minutes backward seek -600 hidden=p["current-tracks/video/image"] and not p["current-tracks/audio"]
90+
91+
Next file playlist-next disabled=playlist_count < 2
92+
Previous file playlist-prev disabled=playlist_count < 2
93+
94+
Next sub-playlist playlist-next-playlist disabled=playlist_count < 2
95+
Previous sub-playlist playlist-prev-playlist disabled=playlist_count < 2
96+
Chapters $chapters
97+
Editions/Titles $editions disabled=get("edition-list/count", 0) < 2
98+
99+
Window
100+
Fullscreen cycle fullscreen checked=fullscreen
101+
Border cycle border checked=border
102+
Always on top cycle ontop checked=ontop
103+
Window scale
104+
50% set window-scale 0.5 checked=math.abs(get("current-window-scale", 0) - 0.5) < 0.1
105+
100% set window-scale 1 checked=math.abs(get("current-window-scale", 0) - 1) < 0.1
106+
200% set window-scale 2 checked=math.abs(get("current-window-scale", 0) - 2) < 0.1
107+
300% set window-scale 3 checked=math.abs(get("current-window-scale", 0) - 3) < 0.1
108+
Screenshot window screenshot window
109+
View
110+
Stats script-binding stats/display-page-1-toggle
111+
File info script-binding stats/display-page-5-toggle
112+
Key bindings script-binding stats/display-page-4-toggle
113+
Time OSD no-osd cycle-values osd-level 3 1 checked=osd_level == 3
114+
Cycle OSC visibility script-binding osc/visibility
115+
Tools
116+
Set/clear A-B loop points ab-loop
117+
Loop file cycle-values loop-file inf no checked=loop_file == "inf"
118+
Loop playlist cycle-values loop-playlist inf no checked=loop_playlist == "inf"
119+
120+
Copy path set clipboard/text ${path} disabled=idle_active
121+
Copy subtitle set clipboard/text ${sub-text} disabled=not sid or p["current-tracks/sub/codec"] == "dvd_subtitle" or p["current-tracks/sub/codec"] == "hdmv_pgs_subtitle"
122+
Copy title set clipboard/text ${media-title} disabled=idle_active
123+
124+
Shuffle playlist-shuffle
125+
Unshuffle playlist-unshuffle
126+
127+
Hardware decoding cycle-values hwdec no auto checked=hwdec_current ~= "no" disabled=p["current-tracks/video/image"] ~= false
128+
Key bindings script-binding select/select-binding
129+
Properties script-binding select/show-properties
130+
Console script-binding commands/open
131+
132+
Edit config file script-binding select/edit-config-file
133+
Edit key bindings script-binding select/edit-input-conf
134+
Online documentation script-binding select/open-docs
135+
136+
Quit quit
137+
Quit watch later quit-watch-later hidden=save_position_on_quit

etc/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ foreach size: icons
99
sources += icon
1010
endforeach
1111

12-
etc_files = ['input.conf', 'builtin.conf']
12+
etc_files = ['input.conf', 'builtin.conf', 'menu.conf']
1313
foreach file: etc_files
1414
etc_file = custom_target(file,
1515
input: file,

0 commit comments

Comments
 (0)