Skip to content

Commit fda04bd

Browse files
committed
rules: parse and apply the shader option
Fixes #1312 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
1 parent 636cb5b commit fda04bd

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/config_libconfig.c

+10
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ parse_rule(struct list_node *rules, config_setting_t *setting, struct script ***
627627
if (animations) {
628628
parse_animations(wopts->animations, animations, out_scripts);
629629
}
630+
631+
config_setting_lookup_string(setting, "shader", &wopts->shader);
630632
return rule;
631633
}
632634

@@ -764,6 +766,14 @@ bool parse_config_libconfig(options_t *opt, const char *config_file) {
764766
config_setting_t *rules = config_lookup(&cfg, "rules");
765767
if (rules) {
766768
parse_rules(&opt->rules, rules, &opt->all_scripts);
769+
c2_condition_list_foreach(&opt->rules, i) {
770+
auto data = (struct window_maybe_options *)c2_condition_get_data(i);
771+
if (data->shader == NULL) {
772+
continue;
773+
}
774+
data->shader = locate_auxiliary_file(
775+
"shaders", data->shader, config_get_include_dir(&cfg));
776+
}
767777
}
768778

769779
// --dbus

src/picom.c

+10
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,16 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
22532253
log_error("Failed to load window shader source file");
22542254
}
22552255

2256+
c2_condition_list_foreach(&ps->o.rules, i) {
2257+
auto data = (struct window_maybe_options *)c2_condition_get_data(i);
2258+
if (data->shader == NULL) {
2259+
continue;
2260+
}
2261+
if (load_shader_source(ps, data->shader)) {
2262+
log_error("Failed to load shader source file for window rules");
2263+
}
2264+
}
2265+
22562266
if (log_get_level_tls() <= LOG_LEVEL_DEBUG) {
22572267
HASH_ITER2(ps->shaders, shader) {
22582268
log_debug("Shader %s:", shader->key);

0 commit comments

Comments
 (0)