diff options
| -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) |
