From 13d354e46d27fd0c433880839abcf9096dbcbc2f Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 5 Aug 2020 22:37:47 +0200 Subject: auto_profiles: add this script This is taken from a somewhat older proof-of-concept script. The basic idea, and most of the implementation, is still the same. The way the profiles are actually defined changed. I still feel bad about this being a Lua script, and running user expressions as Lua code in a vaguely defined environment, but I guess as far as balance of effort/maintenance/results goes, this is fine. It's a bit bloated (the Lua scripting state is at least 150KB or so in total), so in order to enable this by default, I decided it should unload itself by default if no auto-profiles are used. (And currently, it does not actually rescan the profile list if a new config file is loaded some time later, so the script would do nothing anyway if no auto profiles were defined.) This still requires defining inverse profiles for "unapplying" a profile. Also this is still somewhat racy. Both will probably be alleviated to some degree in the future. --- options/options.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'options/options.c') diff --git a/options/options.c b/options/options.c index 4467c106ba..63c99053a8 100644 --- a/options/options.c +++ b/options/options.c @@ -426,6 +426,9 @@ static const m_option_t mp_opts[] = { .flags = UPDATE_BUILTIN_SCRIPTS}, {"load-osd-console", OPT_FLAG(lua_load_console), .flags = UPDATE_BUILTIN_SCRIPTS}, + {"load-auto-profiles", + OPT_CHOICE(lua_load_auto_profiles, {"no", 0}, {"yes", 1}, {"auto", -1}), + .flags = UPDATE_BUILTIN_SCRIPTS}, #endif // ------------------------- stream options -------------------- @@ -944,6 +947,7 @@ static const struct MPOpts mp_default_opts = { .lua_ytdl_raw_options = NULL, .lua_load_stats = 1, .lua_load_console = 1, + .lua_load_auto_profiles = -1, #endif .auto_load_scripts = 1, .loop_times = 1, -- cgit v1.2.3