From 2a3fb338667360987d792f062448de079116a8a9 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Mon, 26 Apr 2021 22:43:10 -0400 Subject: [PATCH] config, fns, manage: terminal classes in config instead of hardcoded in manage() --- config.h | 23 ++++++++++++++++++++--- fns.h | 1 + manage.c | 17 ++++++++++++++--- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/config.h b/config.h index e1a38e4..1d16182 100644 --- a/config.h +++ b/config.h @@ -113,16 +113,33 @@ /* List of window classes to spawn as sticky; * Class values for currently open windows are conveniently shown in the last * column of the 'xshove' command given with no arguments. + * Can be partial strings. * Remember the backslash at the end of non-terminating lines! */ #define AUTOSTICK {\ - "XOsview", \ - "XClock", \ - 0 \ + "XOsview", \ + "XClock", \ + 0 \ +} + +/* List of terminal window classes -- include your favorite terminal here, + * and remove those you don't use. Can be partial strings. + * This array is required. Remember the backslash at the end of non- + * terminating lines! + */ + +#define TERMINALS {\ + "term", \ + "Term", \ + "xvt", \ + "Alacritty", \ + "onsole", \ + 0 \ } /* List of window classes to REQUIRE window sweeping when spawning; + * Can be partial strings. * Remember the backslash at the end of non-terminating lines! */ diff --git a/fns.h b/fns.h index 7e88fa1..ab65645 100644 --- a/fns.h +++ b/fns.h @@ -61,6 +61,7 @@ void setlabel(); void getproto(); void gettrans(); int shouldalwaysdraw(Client* c); +int isterminalwindow(Client* c); /* key.c */ void keypress(); diff --git a/manage.c b/manage.c index 1e2fa8d..45533fa 100644 --- a/manage.c +++ b/manage.c @@ -50,9 +50,7 @@ int manage(Client* c, int mapped) { c->is9term = 0; #endif if (isNew) { - c->is9term = strstr(c->class, "term") || strstr(c->class, "Term") || - strstr(c->class, "urxvt") || strstr(c->class, "URxvt") || - strstr(c->class, "onsole") || strstr(c->class, "Alacritty"); + c->is9term = isterminalwindow(c); isNew = 0; } } else { @@ -573,3 +571,16 @@ int shouldalwaysdraw(Client* c) { return 0; } #endif + +int isterminalwindow(Client* c) { + static char* termnames[] = TERMINALS; + char** t = termnames; + + while (*t) { + if (c && c->class && strstr(c->class, *t)) { + return 1; + } + ++t; + } + return 0; +}