diff options
author | Guido Cella <guido@guidocella.xyz> | 2024-01-11 00:43:12 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2024-02-04 15:12:02 +0000 |
commit | e2284fba180fe33f399835f1d1afdb7871ebef4c (patch) | |
tree | 0cba505e6304fae08c155de9027b401b61a80e51 /player/lua | |
parent | 27cb193f0e87014fbf5121e34da462b46975e53c (diff) | |
download | mpv-e2284fba180fe33f399835f1d1afdb7871ebef4c.tar.bz2 mpv-e2284fba180fe33f399835f1d1afdb7871ebef4c.tar.xz |
command: add load-config-file
Unlike set include mpv.conf, this works after playback has started. It
can be used to auto reload the configuration, e.g. in vim:
autocmd BufWritePost ~/.config/mpv/mpv.conf silent !echo load-config-file %:p | socat - /tmp/mpvsocket
Partially fixes #6362.
Diffstat (limited to 'player/lua')
-rw-r--r-- | player/lua/auto_profiles.lua | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/player/lua/auto_profiles.lua b/player/lua/auto_profiles.lua index 9dca878fc0..a0f580298b 100644 --- a/player/lua/auto_profiles.lua +++ b/player/lua/auto_profiles.lua @@ -164,8 +164,8 @@ local function compile_cond(name, s) return chunk end -local function load_profiles() - for i, v in ipairs(mp.get_property_native("profile-list")) do +local function load_profiles(profiles_property) + for _, v in ipairs(profiles_property) do local cond = v["profile-cond"] if cond and #cond > 0 then local profile = { @@ -182,17 +182,25 @@ local function load_profiles() end end -load_profiles() +mp.observe_property("profile-list", "native", function (_, profiles_property) + profiles = {} + watched_properties = {} + cached_properties = {} + properties_to_profiles = {} + mp.unobserve_property(on_property_change) -if #profiles < 1 and mp.get_property("load-auto-profiles") == "auto" then - -- make it exit immediately - _G.mp_event_loop = function() end - return -end + load_profiles(profiles_property) + + if #profiles < 1 and mp.get_property("load-auto-profiles") == "auto" then + -- make it exit immediately + _G.mp_event_loop = function() end + return + end + + on_idle() -- re-evaluate all profiles immediately +end) mp.register_idle(on_idle) for _, name in ipairs({"on_load", "on_preloaded", "on_before_start_file"}) do mp.add_hook(name, 50, on_hook) end - -on_idle() -- re-evaluate all profiles immediately |