Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
stax76 committed Aug 30, 2024
1 parent 59661db commit 1bcd1b6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documented directly in the script via code comment at the beginning of the scrip
playlist, chapters, profiles, all tracks, audio tracks, video tracks,
subtitle tracks, secondary subtitle tracks, subtitle lines, commands,
properties, options, audio devices, Blu-ray titles, stream quality,
aspect ratio.
aspect ratio, recent files.
- [search_menu](#search_menu) - Searchable menu for bindings, commands, properties, playlist
entries and audio/subtitle tracks.
- [auto_mode.lua](auto_mode.lua) - Use mpv as video player, music player and image viewer.
Expand Down Expand Up @@ -54,13 +54,20 @@ command_palette is a searchable menu for:
- Blu-ray titles
- Stream quality
- Aspect ratio
- Recent files (depends on [recent-menu](https://github.com/natural-harmonia-gropius/recent-menu))

### Installation

1. Save the script at: `<mpv conf folder>/scripts/command_palette.lua`
2. Create a empty text file for options at: `<mpv conf folder>/script-opts/command_palette.conf`
3. Download [extended-menu](https://github.com/Seme4eg/mpv-scripts/blob/master/script-modules/extended-menu.lua)
and save it at: `<mpv conf folder>/script-modules/extended-menu.lua`
4. The Recent Files feature requires [recent-menu](https://github.com/natural-harmonia-gropius/recent-menu)
being installed.
5. For better track media info like showing bitrates, the MediaInfo CLI app must be installed.
Debian/Ubuntu: `sudo apt install mediainfo`
Windows: https://mediaarea.net/en/MediaInfo/Download/Windows
This feature must be enabled in `command_palette.conf` as `use_mediainfo=yes`

### Usage

Expand All @@ -85,6 +92,7 @@ Alt+l script-message-to command_palette show-command-palette "Subtitle Lin
Alt+t script-message-to command_palette show-command-palette "Blu-ray Titles" # Blu-ray Titles
Alt+q script-message-to command_palette show-command-palette "Stream Quality" # Stream Quality
Alt+r script-message-to command_palette show-command-palette "Aspect Ratio" # Aspect Ratio
Alt+e script-message-to command_palette show-command-palette "Recent Files" # Recent Files
```

Available options and their defaults:
Expand All @@ -101,7 +109,7 @@ line_bottom_margin=1
menu_x_padding=5
menu_y_padding=2
use_mediainfo=no # use MediaInfo CLI tool for track info
use_mediainfo=no # yes requires the MediaInfo CLI app being installed
stream_quality_options=2160,1440,1080,720,480
aspect_ratios=4:3,16:9,2.35:1,1.36,1.82,0,-1
```
Expand Down
36 changes: 22 additions & 14 deletions command_palette.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local o = {
menu_x_padding = 5,
menu_y_padding = 2,

use_mediainfo = false, -- use MediaInfo CLI tool for track info
use_mediainfo = false, -- # true requires the MediaInfo CLI app being installed
stream_quality_options = "2160,1440,1080,720,480",
aspect_ratios = "4:3,16:9,2.35:1,1.36,1.82,0,-1",
}
Expand Down Expand Up @@ -446,6 +446,21 @@ local function select_track(property, type, error)
})
end

function hide_osc()
if is_empty(mp.get_property("path")) and not is_older_than_v0_36 then
osc_visibility = mp.get_property_native("user-data/osc/visibility")

if osc_visibility == "auto" or osc_visibility == "always" then
mp.command("script-message osc-visibility never no_osd")
end
end

if uosc_available then
local disable_elements = "window_border, top_bar, timeline, controls, volume, idle_indicator, audio_indicator, buffering_indicator, pause_indicator"
mp.commandv('script-message-to', 'uosc', 'disable-elements', mp.get_script_name(), disable_elements)
end
end

mp.register_script_message("show-command-palette", function (name)
menu_content.list = {}
menu_content.current_i = 1
Expand Down Expand Up @@ -476,6 +491,7 @@ mp.register_script_message("show-command-palette", function (name)
"Stream Quality",
"Aspect Ratio",
"Command Palette",
"Recent Files",
}

for _, item in ipairs(items) do
Expand Down Expand Up @@ -793,6 +809,9 @@ mp.register_script_message("show-command-palette", function (name)
end
elseif name == "Secondary Subtitle" then
select_track("secondary-sid", "sub", "No available subtitle tracks")
elseif name == "Recent Files" then
mp.command("script-message open-recent-menu command-palette")
return
elseif name == "Video Tracks" then
if o.use_mediainfo then
local mi = get_media_info()
Expand Down Expand Up @@ -905,19 +924,7 @@ mp.register_script_message("show-command-palette", function (name)
return
end

if is_empty(mp.get_property("path")) and not is_older_than_v0_36 then
osc_visibility = mp.get_property_native("user-data/osc/visibility")

if osc_visibility == "auto" or osc_visibility == "always" then
mp.command("script-message osc-visibility never no_osd")
end
end

if uosc_available then
local disable_elements = "window_border, top_bar, timeline, controls, volume, idle_indicator, audio_indicator, buffering_indicator, pause_indicator"
mp.commandv('script-message-to', 'uosc', 'disable-elements', mp.get_script_name(), disable_elements)
end

hide_osc()
menu:init(menu_content)
end)

Expand Down Expand Up @@ -960,5 +967,6 @@ mp.register_script_message("show-command-palette-json", function (json)
mp.command_native(tbl.values)
end

hide_osc()
menu:init(menu_content)
end)

0 comments on commit 1bcd1b6

Please sign in to comment.