From b1cf48fb81fa4a8ab7121e8ac93f433b20c607c0 Mon Sep 17 00:00:00 2001 From: Lin Xianyi Date: Wed, 11 Feb 2026 10:17:58 +0800 Subject: [PATCH] feat: atstartup rule that only applies within 60s of startup --- src/config/parse_config.h | 4 ++++ src/mango.c | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/config/parse_config.h b/src/config/parse_config.h index 3220b713..f542fe14 100644 --- a/src/config/parse_config.h +++ b/src/config/parse_config.h @@ -78,6 +78,7 @@ typedef struct { int32_t ignore_maximize; int32_t ignore_minimize; int32_t isnosizehint; + int32_t atstartup; int32_t indleinhibit_when_focus; char *monitor; int32_t offsetx; @@ -2039,6 +2040,7 @@ bool parse_option(Config *config, char *key, char *value) { rule->isnosizehint = -1; rule->indleinhibit_when_focus = -1; rule->isterm = -1; + rule->atstartup = -1; rule->allow_csd = -1; rule->force_maximize = -1; rule->force_tiled_state = -1; @@ -2170,6 +2172,8 @@ bool parse_option(Config *config, char *key, char *value) { rule->isfullscreen = atoi(val); } else if (strcmp(key, "isfakefullscreen") == 0) { rule->isfakefullscreen = atoi(val); + } else if (strcmp(key, "atstartup") == 0) { + rule->atstartup = atoi(val); } else if (strcmp(key, "globalkeybinding") == 0) { char mod_str[256], keysym_str[256]; sscanf(val, "%255[^-]-%255[a-zA-Z]", mod_str, keysym_str); diff --git a/src/mango.c b/src/mango.c index bdafcc58..f682633f 100644 --- a/src/mango.c +++ b/src/mango.c @@ -813,6 +813,7 @@ static void pre_caculate_before_arrange(Monitor *m, bool want_animation, /* variables */ static const char broken[] = "broken"; static pid_t child_pid = -1; +static uint32_t startup_time; static int32_t locked; static uint32_t locked_mods = 0; static void *exclusive_focus; @@ -1432,10 +1433,14 @@ void applyrules(Client *c) { if (!is_window_rule_matches(r, appid, title)) continue; + // rule is after 60s of startup, do not apply + if (r->atstartup && get_now_in_ms() - startup_time > 60 * 1000) + continue; + // set general properties apply_rule_properties(c, r); - // // set tags + // set tags if (r->tags > 0) { newtags |= r->tags; } else if (parent) { @@ -5757,6 +5762,9 @@ void setup(void) { } sync_keymap = wl_event_loop_add_timer(wl_display_get_event_loop(dpy), synckeymap, NULL); + + // store the startup time for at-startup rules to check against + startup_time = get_now_in_ms(); #endif }