From 1bcd1b6f2ebeb285ca9647945c542781557ba9e7 Mon Sep 17 00:00:00 2001 From: stax76 Date: Fri, 30 Aug 2024 06:46:48 +0200 Subject: [PATCH] misc --- README.md | 12 ++++++++++-- command_palette.lua | 36 ++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 2457cfe..2e6e762 100644 --- a/README.md +++ b/README.md @@ -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. @@ -54,6 +54,7 @@ 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 @@ -61,6 +62,12 @@ command_palette is a searchable menu for: 2. Create a empty text file for options at: `/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: `/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 @@ -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: @@ -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 ``` diff --git a/command_palette.lua b/command_palette.lua index 8d289b0..082f18a 100644 --- a/command_palette.lua +++ b/command_palette.lua @@ -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", } @@ -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 @@ -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 @@ -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() @@ -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) @@ -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)