diff options
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | config.arg.h | 11 | ||||
| -rw-r--r-- | config.default.h | 11 | ||||
| -rw-r--r-- | config.mk | 2 | ||||
| -rw-r--r-- | dmenu.1 | 27 | ||||
| -rw-r--r-- | dmenu.h | 6 | ||||
| -rw-r--r-- | main.c | 52 |
7 files changed, 67 insertions, 48 deletions
| @@ -19,11 +19,7 @@ options: | |||
| 19 | @echo CC $< | 19 | @echo CC $< |
| 20 | @${CC} -c ${CFLAGS} $< | 20 | @${CC} -c ${CFLAGS} $< |
| 21 | 21 | ||
| 22 | ${OBJ}: dmenu.h config.h config.mk | 22 | ${OBJ}: dmenu.h config.mk |
| 23 | |||
| 24 | config.h: | ||
| 25 | @echo creating $@ from config.default.h | ||
| 26 | @cp config.default.h $@ | ||
| 27 | 23 | ||
| 28 | dmenu: ${OBJ} | 24 | dmenu: ${OBJ} |
| 29 | @echo LD $@ | 25 | @echo LD $@ |
diff --git a/config.arg.h b/config.arg.h deleted file mode 100644 index 5b99a2c..0000000 --- a/config.arg.h +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | ||
| 3 | * See LICENSE file for license details. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #define FONT "-*-terminus-medium-*-*-*-12-*-*-*-*-*-iso10646-*" | ||
| 7 | #define SELBGCOLOR "#333366" | ||
| 8 | #define SELFGCOLOR "#eeeeee" | ||
| 9 | #define NORMBGCOLOR "#333333" | ||
| 10 | #define NORMFGCOLOR "#dddddd" | ||
| 11 | #define STDIN_TIMEOUT 3 /* seconds */ | ||
diff --git a/config.default.h b/config.default.h deleted file mode 100644 index 0bae3a1..0000000 --- a/config.default.h +++ /dev/null | |||
| @@ -1,11 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | ||
| 3 | * See LICENSE file for license details. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #define FONT "fixed" | ||
| 7 | #define SELBGCOLOR "#666699" | ||
| 8 | #define SELFGCOLOR "#eeeeee" | ||
| 9 | #define NORMBGCOLOR "#333366" | ||
| 10 | #define NORMFGCOLOR "#cccccc" | ||
| 11 | #define STDIN_TIMEOUT 3 /* seconds */ | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | # dmenu version | 1 | # dmenu version |
| 2 | VERSION = 1.0 | 2 | VERSION = 1.1 |
| 3 | 3 | ||
| 4 | # Customize below to fit your system | 4 | # Customize below to fit your system |
| 5 | 5 | ||
| @@ -3,6 +3,12 @@ | |||
| 3 | dmenu \- dynamic menu | 3 | dmenu \- dynamic menu |
| 4 | .SH SYNOPSIS | 4 | .SH SYNOPSIS |
| 5 | .B dmenu | 5 | .B dmenu |
| 6 | .RB [ \-font <name> ] | ||
| 7 | .RB [ \-normbg <color> ] | ||
| 8 | .RB [ \-normfg <color> ] | ||
| 9 | .RB [ \-selbg <color> ] | ||
| 10 | .RB [ \-selfg <color> ] | ||
| 11 | .RB [ \-t <seconds> ] | ||
| 6 | .RB [ \-v ] | 12 | .RB [ \-v ] |
| 7 | .SH DESCRIPTION | 13 | .SH DESCRIPTION |
| 8 | .SS Overview | 14 | .SS Overview |
| @@ -12,6 +18,24 @@ It manages huge amounts (up to 10.000 and more) of user defined menu items | |||
| 12 | efficiently. | 18 | efficiently. |
| 13 | .SS Options | 19 | .SS Options |
| 14 | .TP | 20 | .TP |
| 21 | .B \-font <name> | ||
| 22 | defines the font. | ||
| 23 | .TP | ||
| 24 | .B \-normbg <color> | ||
| 25 | defines the normal background color (#RGB, #RRGGBB, and color names are supported). | ||
| 26 | .TP | ||
| 27 | .B \-normfg <color> | ||
| 28 | defines the normal foreground color (#RGB, #RRGGBB, and color names are supported). | ||
| 29 | .TP | ||
| 30 | .B \-selbg <color> | ||
| 31 | defines the selected background color (#RGB, #RRGGBB, and color names are supported). | ||
| 32 | .TP | ||
| 33 | .B \-selfg <color> | ||
| 34 | defines the selected foreground color (#RGB, #RRGGBB, and color names are supported). | ||
| 35 | .TP | ||
| 36 | .B \-t <seconds> | ||
| 37 | defines the seconds to wait for standard input, before exiting (default is 3). | ||
| 38 | .TP | ||
| 15 | .B \-v | 39 | .B \-v |
| 16 | prints version information to standard output, then exits. | 40 | prints version information to standard output, then exits. |
| 17 | .SH USAGE | 41 | .SH USAGE |
| @@ -52,8 +76,5 @@ Remove enough characters from the input field to change its filtering effect. | |||
| 52 | .TP | 76 | .TP |
| 53 | .B Control-u | 77 | .B Control-u |
| 54 | Remove all characters from the input field. | 78 | Remove all characters from the input field. |
| 55 | .SH CUSTOMIZATION | ||
| 56 | dmenu is customized by creating a custom config.h and (re)compiling the source | ||
| 57 | code. This keeps it fast, secure and simple. | ||
| 58 | .SH SEE ALSO | 79 | .SH SEE ALSO |
| 59 | .BR dwm (1) | 80 | .BR dwm (1) |
| @@ -3,10 +3,14 @@ | |||
| 3 | * See LICENSE file for license details. | 3 | * See LICENSE file for license details. |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #include "config.h" | ||
| 7 | #include <X11/Xlib.h> | 6 | #include <X11/Xlib.h> |
| 8 | #include <X11/Xlocale.h> | 7 | #include <X11/Xlocale.h> |
| 9 | 8 | ||
| 9 | #define FONT "fixed" | ||
| 10 | #define NORMBGCOLOR "#333366" | ||
| 11 | #define NORMFGCOLOR "#cccccc" | ||
| 12 | #define SELBGCOLOR "#666699" | ||
| 13 | #define SELFGCOLOR "#eeeeee" | ||
| 10 | #define SPACE 30 /* px */ | 14 | #define SPACE 30 /* px */ |
| 11 | 15 | ||
| 12 | /* color */ | 16 | /* color */ |
| @@ -283,19 +283,41 @@ DC dc = {0}; | |||
| 283 | 283 | ||
| 284 | int | 284 | int |
| 285 | main(int argc, char *argv[]) { | 285 | main(int argc, char *argv[]) { |
| 286 | char *font = FONT; | ||
| 286 | char *maxname; | 287 | char *maxname; |
| 288 | char *normbg = NORMBGCOLOR; | ||
| 289 | char *normfg = NORMFGCOLOR; | ||
| 290 | char *selbg = SELBGCOLOR; | ||
| 291 | char *selfg = SELFGCOLOR; | ||
| 287 | fd_set rd; | 292 | fd_set rd; |
| 293 | int i; | ||
| 288 | struct timeval timeout; | 294 | struct timeval timeout; |
| 289 | Item *i; | 295 | Item *itm; |
| 290 | XEvent ev; | 296 | XEvent ev; |
| 291 | XSetWindowAttributes wa; | 297 | XSetWindowAttributes wa; |
| 292 | 298 | ||
| 293 | if(argc == 2 && !strncmp("-v", argv[1], 3)) { | 299 | timeout.tv_usec = 0; |
| 294 | fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); | 300 | timeout.tv_sec = 3; |
| 295 | exit(EXIT_SUCCESS); | 301 | /* command line args */ |
| 296 | } | 302 | for(i = 1; i < argc; i++) |
| 297 | else if(argc != 1) | 303 | if(!strncmp(argv[i], "-font", 6)) |
| 298 | eprint("usage: dmenu [-v]\n"); | 304 | font = argv[++i]; |
| 305 | else if(!strncmp(argv[i], "-normbg", 8)) | ||
| 306 | normbg = argv[++i]; | ||
| 307 | else if(!strncmp(argv[i], "-normfg", 8)) | ||
| 308 | normfg = argv[++i]; | ||
| 309 | else if(!strncmp(argv[i], "-selbg", 7)) | ||
| 310 | selbg = argv[++i]; | ||
| 311 | else if(!strncmp(argv[i], "-selfg", 7)) | ||
| 312 | selfg = argv[++i]; | ||
| 313 | else if(!strncmp(argv[i], "-t", 3)) | ||
| 314 | timeout.tv_sec = atoi(argv[++i]); | ||
| 315 | else if(!strncmp(argv[i], "-v", 3)) { | ||
| 316 | fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); | ||
| 317 | exit(EXIT_SUCCESS); | ||
| 318 | } | ||
| 319 | else | ||
| 320 | eprint("usage: dmenu [-font <name>] [-{norm,sel}{bg,fg} <color>] [-t <seconds>] [-v]\n", stdout); | ||
| 299 | 321 | ||
| 300 | dpy = XOpenDisplay(0); | 322 | dpy = XOpenDisplay(0); |
| 301 | if(!dpy) | 323 | if(!dpy) |
| @@ -312,8 +334,6 @@ main(int argc, char *argv[]) { | |||
| 312 | GrabModeAsync, CurrentTime) != GrabSuccess) | 334 | GrabModeAsync, CurrentTime) != GrabSuccess) |
| 313 | usleep(1000); | 335 | usleep(1000); |
| 314 | 336 | ||
| 315 | timeout.tv_usec = 0; | ||
| 316 | timeout.tv_sec = STDIN_TIMEOUT; | ||
| 317 | FD_ZERO(&rd); | 337 | FD_ZERO(&rd); |
| 318 | FD_SET(STDIN_FILENO, &rd); | 338 | FD_SET(STDIN_FILENO, &rd); |
| 319 | if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1) | 339 | if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1) |
| @@ -321,11 +341,11 @@ main(int argc, char *argv[]) { | |||
| 321 | maxname = readstdin(); | 341 | maxname = readstdin(); |
| 322 | 342 | ||
| 323 | /* style */ | 343 | /* style */ |
| 324 | dc.sel[ColBG] = getcolor(SELBGCOLOR); | 344 | dc.sel[ColBG] = getcolor(selbg); |
| 325 | dc.sel[ColFG] = getcolor(SELFGCOLOR); | 345 | dc.sel[ColFG] = getcolor(selfg); |
| 326 | dc.norm[ColBG] = getcolor(NORMBGCOLOR); | 346 | dc.norm[ColBG] = getcolor(normbg); |
| 327 | dc.norm[ColFG] = getcolor(NORMFGCOLOR); | 347 | dc.norm[ColFG] = getcolor(normfg); |
| 328 | setfont(FONT); | 348 | setfont(font); |
| 329 | 349 | ||
| 330 | wa.override_redirect = 1; | 350 | wa.override_redirect = 1; |
| 331 | wa.background_pixmap = ParentRelative; | 351 | wa.background_pixmap = ParentRelative; |
| @@ -373,10 +393,10 @@ main(int argc, char *argv[]) { | |||
| 373 | } | 393 | } |
| 374 | 394 | ||
| 375 | while(allitems) { | 395 | while(allitems) { |
| 376 | i = allitems->next; | 396 | itm = allitems->next; |
| 377 | free(allitems->text); | 397 | free(allitems->text); |
| 378 | free(allitems); | 398 | free(allitems); |
| 379 | allitems = i; | 399 | allitems = itm; |
| 380 | } | 400 | } |
| 381 | if(dc.font.set) | 401 | if(dc.font.set) |
| 382 | XFreeFontSet(dpy, dc.font.set); | 402 | XFreeFontSet(dpy, dc.font.set); |
