diff options
Diffstat (limited to 'config.lua')
| -rw-r--r-- | config.lua | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -7,6 +7,9 @@ local mp_utils = require('mp.utils') local config = {} +local script_name = mp.get_script_name() +local script_dir = mp.get_script_directory() + -- font size is in units of osd height, which is scaled to 720 config.font_size = 20 @@ -65,14 +68,34 @@ config.icon = { menu_btn = '≡', } -local script_dir = mp.get_script_directory() config.tmp_dir = os.getenv('XDG_RUNTIME_DIR') or '/tmp' config.cache_dir = mp_utils.join_path(script_dir, 'cache') config.img_dir = mp_utils.join_path(script_dir, 'img') config.favourites_file = mp_utils.join_path(script_dir, 'favourites.json') --- flatten keys into `foo.bar.baz' form for script-opt overrides +-- flatten keys into `foo.bar.baz' form for script-opt overrides. unrecognised +-- keys are manually read and added to opts, as read_options only handles keys +-- with default values. local opts = util.flatten_table(config) +local f = io.open( + mp.command_native( + {'expand-path', '~~/script-opts/' .. script_name .. '.conf'}), + 'r') +if f then + for line in f:lines() do + if #line > 0 then + local k = line:match('^([^=]*)=') + opts[k] = opts[k] or '' + end + end + f:close() +end +for k, v in pairs(mp.get_property_native('script-opts')) do + if k:find(script_name .. '-', 1, true) == 1 then + local pk = k:sub(#script_name + 2) + opts[pk] = opts[pk] or '' + end +end mp_options.read_options(opts) util.unflatten_table(opts, config) |
