From fda04bdabb175598e2100762bcc43361dca1d8de Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Tue, 13 Aug 2024 02:43:55 +0100 Subject: [PATCH] rules: parse and apply the `shader` option Fixes #1312 Signed-off-by: Yuxuan Shui --- src/config_libconfig.c | 10 ++++++++++ src/picom.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/config_libconfig.c b/src/config_libconfig.c index a90a00a0c2..c070db27d6 100644 --- a/src/config_libconfig.c +++ b/src/config_libconfig.c @@ -627,6 +627,8 @@ parse_rule(struct list_node *rules, config_setting_t *setting, struct script *** if (animations) { parse_animations(wopts->animations, animations, out_scripts); } + + config_setting_lookup_string(setting, "shader", &wopts->shader); return rule; } @@ -764,6 +766,14 @@ bool parse_config_libconfig(options_t *opt, const char *config_file) { config_setting_t *rules = config_lookup(&cfg, "rules"); if (rules) { parse_rules(&opt->rules, rules, &opt->all_scripts); + c2_condition_list_foreach(&opt->rules, i) { + auto data = (struct window_maybe_options *)c2_condition_get_data(i); + if (data->shader == NULL) { + continue; + } + data->shader = locate_auxiliary_file( + "shaders", data->shader, config_get_include_dir(&cfg)); + } } // --dbus diff --git a/src/picom.c b/src/picom.c index 8bc0f158be..a46ae92f70 100644 --- a/src/picom.c +++ b/src/picom.c @@ -2253,6 +2253,16 @@ static session_t *session_init(int argc, char **argv, Display *dpy, log_error("Failed to load window shader source file"); } + c2_condition_list_foreach(&ps->o.rules, i) { + auto data = (struct window_maybe_options *)c2_condition_get_data(i); + if (data->shader == NULL) { + continue; + } + if (load_shader_source(ps, data->shader)) { + log_error("Failed to load shader source file for window rules"); + } + } + if (log_get_level_tls() <= LOG_LEVEL_DEBUG) { HASH_ITER2(ps->shaders, shader) { log_debug("Shader %s:", shader->key);