From d11991d997e34c2b5b07efdd123e7457aafe75a6 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 19 Sep 2023 10:06:27 -0400 Subject: [PATCH] cleanup default config - Add a flag for minimium width on centered dmenu - Change border_width to borderpx for consistency - Wire up additional variables to xresourcs --- config.def.h | 14 ++++++++++---- dmenu.c | 8 +++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/config.def.h b/config.def.h index ff44ce4..beaba62 100644 --- a/config.def.h +++ b/config.def.h @@ -1,9 +1,9 @@ /* See LICENSE file for copyright and license details. */ /* Default settings; can be overriden by command line. */ -static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ -static int centered = 0; /* -c option; centers dmenu on screen */ -static int min_width = 500; /* minimum width when centered */ +static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */ +static int centered = 0; /* -c option; centers dmenu on screen */ +static int min_width = 500; /* -cw option; minimum width when centered */ static int fuzzy = 1; /* -F option; if 0, dmenu doesn't use fuzzy matching */ /* -fn option overrides fonts[0]; default X11 font or font set */ @@ -40,7 +40,7 @@ static unsigned int columns = 0; static const char worddelimiters[] = " "; /* Size of the window border */ -static unsigned int border_width = 0; +static unsigned int borderpx = 0; /* * Xresources preferences to load at startup @@ -54,4 +54,10 @@ ResourcePref resources[] = { { "selbgcolor", STRING, &selbgcolor }, { "selhlcolor", STRING, &selhlcolor }, { "prompt", STRING, &prompt }, + { "centered", INTEGER, ¢ered }, + { "min_width", INTEGER, &min_width }, + { "fuzzy", INTEGER, &fuzzy }, + { "lines", INTEGER, &lines }, + { "columns", INTEGER, &columns }, + { "borderpx", INTEGER, &borderpx }, }; diff --git a/dmenu.c b/dmenu.c index 465bffe..1144e0a 100644 --- a/dmenu.c +++ b/dmenu.c @@ -953,10 +953,10 @@ setup(void) swa.override_redirect = True; swa.background_pixel = scheme[SchemeNorm][ColBg].pixel; swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask; - win = XCreateWindow(dpy, root, x, y, mw, mh, border_width, + win = XCreateWindow(dpy, root, x, y, mw, mh, borderpx, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect | CWBackPixel | CWEventMask, &swa); - if (border_width) + if (borderpx) XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel); XSetClassHint(dpy, win, &ch); @@ -1011,6 +1011,8 @@ main(int argc, char *argv[]) fast = 1; else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */ centered = 1; + else if (!strcmp(argv[i], "-cw")) /* centered min width on screen */ + min_width = atoi(argv[++i]); else if (!strcmp(argv[i], "-F")) /* grabs keyboard before reading stdin */ fuzzy = 0; else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ @@ -1050,7 +1052,7 @@ main(int argc, char *argv[]) else if (!strcmp(argv[i], "-w")) /* embedding window id */ embed = argv[++i]; else if (!strcmp(argv[i], "-bw")) - border_width = atoi(argv[++i]); /* border width */ + borderpx = atoi(argv[++i]); /* border width */ else usage();