aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dmenu.15
-rw-r--r--dmenu.c96
2 files changed, 53 insertions, 48 deletions
diff --git a/dmenu.1 b/dmenu.1
index 08d103f..d2a93d1 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -7,6 +7,8 @@ dmenu \- dynamic menu
7.RB [ \-i ] 7.RB [ \-i ]
8.RB [ \-l 8.RB [ \-l
9.IR lines ] 9.IR lines ]
10.RB [ \-m
11.IR monitor ]
10.RB [ \-p 12.RB [ \-p
11.IR prompt ] 13.IR prompt ]
12.RB [ \-fn 14.RB [ \-fn
@@ -51,6 +53,9 @@ dmenu matches menu items case insensitively.
51.BI \-l " lines" 53.BI \-l " lines"
52dmenu lists items vertically, with the given number of lines. 54dmenu lists items vertically, with the given number of lines.
53.TP 55.TP
56.BI \-m " monitor"
57dmenu appears on the given Xinerama screen.
58.TP
54.BI \-p " prompt" 59.BI \-p " prompt"
55defines the prompt to be displayed to the left of the input field. 60defines the prompt to be displayed to the left of the input field.
56.TP 61.TP
diff --git a/dmenu.c b/dmenu.c
index 5c77560..a24dfe3 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -63,6 +63,52 @@ static Window root, win;
63 63
64static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; 64static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
65 65
66int
67main(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
66void 112void
67appenditem(Item *item, Item **list, Item **last) { 113appenditem(Item *item, Item **list, Item **last) {
68 if(!*last) 114 if(!*last)
@@ -490,53 +536,7 @@ setup(void) {
490 536
491void 537void
492usage(void) { 538usage(void) {
493 fputs("usage: dmenu [-b] [-i] [-l lines] [-p prompt] [-fn font] [-nb color]\n" 539 fputs("usage: dmenu [-b] [-i] [-l lines] [-m monitor] [-p prompt] [-fn font]\n"
494 " [-nf color] [-sb color] [-sf color] [-v]\n", stderr); 540 " [-nb color] [-nf color] [-sb color] [-sf color] [-v]\n", stderr);
495 exit(EXIT_FAILURE); 541 exit(EXIT_FAILURE);
496} 542}
497
498int
499main(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}