removed config.h stuff, made dwm configurable due to command line options 5c0d28e4
arg@mmvi · 2006-09-26 13:20 7 file(s) · +67 −48
Makefile +1 −5
19 19
	@echo CC $<
20 20
	@${CC} -c ${CFLAGS} $<
21 21
22 -
${OBJ}: dmenu.h config.h config.mk
23 -
24 -
config.h:
25 -
	@echo creating $@ from config.default.h
26 -
	@cp config.default.h $@
22 +
${OBJ}: dmenu.h config.mk
27 23
28 24
dmenu: ${OBJ}
29 25
	@echo LD $@
config.arg.h (deleted) +0 −11
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 */
config.default.h (deleted) +0 −11
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 */
config.mk +1 −1
1 1
# dmenu version
2 -
VERSION = 1.0
2 +
VERSION = 1.1
3 3
4 4
# Customize below to fit your system
5 5
dmenu.1 +24 −3
3 3
dmenu \- dynamic menu
4 4
.SH SYNOPSIS
5 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 12
.RB [ \-v ]
7 13
.SH DESCRIPTION
8 14
.SS Overview
11 17
It manages huge amounts (up to 10.000 and more) of user defined menu items
12 18
efficiently.
13 19
.SS Options
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).
14 38
.TP
15 39
.B \-v
16 40
prints version information to standard output, then exits.
52 76
.TP
53 77
.B Control-u
54 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 79
.SH SEE ALSO
59 80
.BR dwm (1)
dmenu.h +5 −1
3 3
 * See LICENSE file for license details.
4 4
 */
5 5
6 -
#include "config.h"
7 6
#include <X11/Xlib.h>
8 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 14
#define SPACE		30 /* px */
11 15
12 16
/* color */
main.c +36 −16
283 283
284 284
int
285 285
main(int argc, char *argv[]) {
286 +
	char *font = FONT;
286 287
	char *maxname;
288 +
	char *normbg = NORMBGCOLOR;
289 +
	char *normfg = NORMFGCOLOR;
290 +
	char *selbg = SELBGCOLOR;
291 +
	char *selfg = SELFGCOLOR;
287 292
	fd_set rd;
293 +
	int i;
288 294
	struct timeval timeout;
289 -
	Item *i;
295 +
	Item *itm;
290 296
	XEvent ev;
291 297
	XSetWindowAttributes wa;
292 298
293 -
	if(argc == 2 && !strncmp("-v", argv[1], 3)) {
294 -
		fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
295 -
		exit(EXIT_SUCCESS);
296 -
	}
297 -
	else if(argc != 1)
298 -
		eprint("usage: dmenu [-v]\n");
299 +
	timeout.tv_usec = 0;
300 +
	timeout.tv_sec = 3;
301 +
	/* command line args */
302 +
	for(i = 1; i < argc; i++)
303 +
		if(!strncmp(argv[i], "-font", 6))
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 322
	dpy = XOpenDisplay(0);
301 323
	if(!dpy)
312 334
			 GrabModeAsync, CurrentTime) != GrabSuccess)
313 335
		usleep(1000);
314 336
315 -
	timeout.tv_usec = 0;
316 -
	timeout.tv_sec = STDIN_TIMEOUT;
317 337
	FD_ZERO(&rd);
318 338
	FD_SET(STDIN_FILENO, &rd);
319 339
	if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1)
321 341
	maxname = readstdin();
322 342
323 343
	/* style */
324 -
	dc.sel[ColBG] = getcolor(SELBGCOLOR);
325 -
	dc.sel[ColFG] = getcolor(SELFGCOLOR);
326 -
	dc.norm[ColBG] = getcolor(NORMBGCOLOR);
327 -
	dc.norm[ColFG] = getcolor(NORMFGCOLOR);
328 -
	setfont(FONT);
344 +
	dc.sel[ColBG] = getcolor(selbg);
345 +
	dc.sel[ColFG] = getcolor(selfg);
346 +
	dc.norm[ColBG] = getcolor(normbg);
347 +
	dc.norm[ColFG] = getcolor(normfg);
348 +
	setfont(font);
329 349
330 350
	wa.override_redirect = 1;
331 351
	wa.background_pixmap = ParentRelative;
373 393
	}
374 394
375 395
	while(allitems) {
376 -
		i = allitems->next;
396 +
		itm = allitems->next;
377 397
		free(allitems->text);
378 398
		free(allitems);
379 -
		allitems = i;
399 +
		allitems = itm;
380 400
	}
381 401
	if(dc.font.set)
382 402
		XFreeFontSet(dpy, dc.font.set);