diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2023-01-31 09:11:21 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2023-01-31 09:11:21 -0500 |
| commit | 8d1417b53842b9667f2a6b049cf33dabb47c3f4e (patch) | |
| tree | 33c879de45c0afe7caf96139fe174c26ee5cebaf | |
| parent | 486c7d89afb1fa49e792787f358ca40910ae17fe (diff) | |
| download | dwm-8d1417b53842b9667f2a6b049cf33dabb47c3f4e.tar.gz dwm-8d1417b53842b9667f2a6b049cf33dabb47c3f4e.tar.xz | |
Set DMENU_FLAGS in the environment.
| -rw-r--r-- | config.def.h | 3 | ||||
| -rw-r--r-- | dwm.c | 23 |
2 files changed, 25 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h index 418cdbe..9f57f50 100644 --- a/config.def.h +++ b/config.def.h @@ -1,6 +1,7 @@ /* See LICENSE file for copyright and license details. */ /* appearance */ +#define DMENU_FLAGS "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4 static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ @@ -65,7 +66,7 @@ static const Layout layouts[] = { /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *dmenucmd[] = { "dmenu_run", DMENU_FLAGS, NULL }; static const char *termcmd[] = { "st", NULL }; static const Key keys[] = { @@ -245,6 +245,7 @@ static int xerror(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); +static void setDmenuFlags(); /* variables */ static const char broken[] = "broken"; @@ -2421,6 +2422,27 @@ zoom(const Arg *arg) pop(c); } +/* Make central configuration of dmenu appearance easy by sucking it out + * of our config.h + */ +void +setDmenuFlags() { + const char *dmenu_flags[] = { DMENU_FLAGS, NULL }; + char *dflags = ecalloc(1024, sizeof(char)); + char *tmp = NULL; + for (int i = 0; i<sizeof(dmenu_flags)/sizeof(dmenu_flags[0]); i++) { + if (dmenu_flags[i] == NULL) + break; + tmp = strdup(dflags); + sprintf(dflags, "%s %s", tmp, dmenu_flags[i]); + free(tmp); + tmp = NULL; + } + setenv("DMENU_FLAGS", dflags, 1); + free(dflags); + dflags = NULL; +} + int main(int argc, char *argv[]) { @@ -2433,6 +2455,7 @@ main(int argc, char *argv[]) if (!(dpy = XOpenDisplay(NULL))) die("dwm: cannot open display"); checkotherwm(); + setDmenuFlags(); setup(); #ifdef __OpenBSD__ if (pledge("stdio rpath proc exec", NULL) == -1) |
