Skip to content

Commit

Permalink
fix: menu config with mpv.net (#776)
Browse files Browse the repository at this point in the history
mpv.net v7 returns the whole input.conf content instead of the path for
the `input-conf` property.
  • Loading branch information
christoph-heinrich committed Nov 6, 2023
1 parent 9c087ef commit ed42152
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/uosc/lib/menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -341,20 +341,33 @@ do
if items then return items end

local input_conf_property = mp.get_property_native('input-conf')
local input_conf = input_conf_property == '' and '~~/input.conf' or input_conf_property
local input_conf_path = mp.command_native({'expand-path', input_conf})
local input_conf_meta, meta_error = utils.file_info(input_conf_path)

-- File doesn't exist
if not input_conf_meta or not input_conf_meta.is_file then
items = create_default_menu_items()
return items
local input_conf_iterator
if input_conf_property:sub(1, 9) == 'memory://' then
-- mpv.net v7
local input_conf_lines = split(input_conf_property:sub(10), '\n')
local i = 0
input_conf_iterator = function()
i = i + 1
return input_conf_lines[i]
end
else
local input_conf = input_conf_property == '' and '~~/input.conf' or input_conf_property
local input_conf_path = mp.command_native({'expand-path', input_conf})
local input_conf_meta, meta_error = utils.file_info(input_conf_path)

-- File doesn't exist
if not input_conf_meta or not input_conf_meta.is_file then
items = create_default_menu_items()
return items
end

input_conf_iterator = io.lines(input_conf_path)
end

local main_menu = {items = {}, items_by_command = {}}
local by_id = {}

for line in io.lines(input_conf_path) do
for line in input_conf_iterator do
local key, command, comment = string.match(line, '%s*([%S]+)%s+(.-)%s+#%s*(.-)%s*$')
local title = ''

Expand Down

0 comments on commit ed42152

Please # to comment.