moved main, updated args 8d9ade36
Connor Lane Smith · 2010-11-17 04:33 2 file(s) · +53 −48
dmenu.1 +5 −0
7 7
.RB [ \-i ]
8 8
.RB [ \-l
9 9
.IR lines ]
10 +
.RB [ \-m
11 +
.IR monitor ]
10 12
.RB [ \-p
11 13
.IR prompt ]
12 14
.RB [ \-fn
50 52
.TP
51 53
.BI \-l " lines"
52 54
dmenu lists items vertically, with the given number of lines.
55 +
.TP
56 +
.BI \-m " monitor"
57 +
dmenu appears on the given Xinerama screen.
53 58
.TP
54 59
.BI \-p " prompt"
55 60
defines the prompt to be displayed to the left of the input field.
dmenu.c +48 −48
63 63
64 64
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
65 65
66 +
int
67 +
main(int argc, char *argv[]) {
68 +
	int i;
69 +
70 +
	progname = "dmenu";
71 +
	for(i = 1; i < argc; i++)
72 +
		/* single flags */
73 +
		if(!strcmp(argv[i], "-v")) {
74 +
			fputs("dmenu-"VERSION", © 2006-2010 dmenu engineers, see LICENSE for details\n", stdout);
75 +
			exit(EXIT_SUCCESS);
76 +
		}
77 +
		else if(!strcmp(argv[i], "-b"))
78 +
			topbar = False;
79 +
		else if(!strcmp(argv[i], "-i"))
80 +
			fstrncmp = strncasecmp;
81 +
		else if(i == argc-1)
82 +
			usage();
83 +
		/* double flags */
84 +
		else if(!strcmp(argv[i], "-l"))
85 +
			lines = atoi(argv[++i]);
86 +
		else if(!strcmp(argv[i], "-m"))
87 +
			monitor = atoi(argv[++i]);
88 +
		else if(!strcmp(argv[i], "-p"))
89 +
			prompt = argv[++i];
90 +
		else if(!strcmp(argv[i], "-fn"))
91 +
			font = argv[++i];
92 +
		else if(!strcmp(argv[i], "-nb"))
93 +
			normbgcolor = argv[++i];
94 +
		else if(!strcmp(argv[i], "-nf"))
95 +
			normfgcolor = argv[++i];
96 +
		else if(!strcmp(argv[i], "-sb"))
97 +
			selbgcolor = argv[++i];
98 +
		else if(!strcmp(argv[i], "-sf"))
99 +
			selfgcolor = argv[++i];
100 +
		else
101 +
			usage();
102 +
103 +
	dc = initdc();
104 +
	initfont(dc, font);
105 +
	readstdin();
106 +
	setup();
107 +
	run();
108 +
109 +
	return EXIT_FAILURE;  /* should not reach */
110 +
}
111 +
66 112
void
67 113
appenditem(Item *item, Item **list, Item **last) {
68 114
	if(!*last)
490 536
491 537
void
492 538
usage(void) {
493 -
	fputs("usage: dmenu [-b] [-i] [-l lines] [-p prompt] [-fn font] [-nb color]\n"
494 -
	      "             [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
539 +
	fputs("usage: dmenu [-b] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n"
540 +
	      "             [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
495 541
	exit(EXIT_FAILURE);
496 542
}
497 -
498 -
int
499 -
main(int argc, char *argv[]) {
500 -
	int i;
501 -
502 -
	progname = "dmenu";
503 -
	for(i = 1; i < argc; i++)
504 -
		/* single flags */
505 -
		if(!strcmp(argv[i], "-v")) {
506 -
			fputs("dmenu-"VERSION", © 2006-2010 dmenu engineers, see LICENSE for details\n", stdout);
507 -
			exit(EXIT_SUCCESS);
508 -
		}
509 -
		else if(!strcmp(argv[i], "-b"))
510 -
			topbar = False;
511 -
		else if(!strcmp(argv[i], "-i"))
512 -
			fstrncmp = strncasecmp;
513 -
		else if(i == argc-1)
514 -
			usage();
515 -
		/* double flags */
516 -
		else if(!strcmp(argv[i], "-l"))
517 -
			lines = atoi(argv[++i]);
518 -
		else if(!strcmp(argv[i], "-m"))
519 -
			monitor = atoi(argv[++i]);
520 -
		else if(!strcmp(argv[i], "-p"))
521 -
			prompt = argv[++i];
522 -
		else if(!strcmp(argv[i], "-fn"))
523 -
			font = argv[++i];
524 -
		else if(!strcmp(argv[i], "-nb"))
525 -
			normbgcolor = argv[++i];
526 -
		else if(!strcmp(argv[i], "-nf"))
527 -
			normfgcolor = argv[++i];
528 -
		else if(!strcmp(argv[i], "-sb"))
529 -
			selbgcolor = argv[++i];
530 -
		else if(!strcmp(argv[i], "-sf"))
531 -
			selfgcolor = argv[++i];
532 -
		else
533 -
			usage();
534 -
535 -
	dc = initdc();
536 -
	initfont(dc, font);
537 -
	readstdin();
538 -
	setup();
539 -
	run();
540 -
541 -
	return EXIT_FAILURE;  /* should not reach */
542 -
}