diff options
| -rw-r--r-- | dmenu.1 | 5 | ||||
| -rw-r--r-- | dmenu.c | 96 |
2 files changed, 53 insertions, 48 deletions
| @@ -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" |
| 52 | dmenu lists items vertically, with the given number of lines. | 54 | dmenu lists items vertically, with the given number of lines. |
| 53 | .TP | 55 | .TP |
| 56 | .BI \-m " monitor" | ||
| 57 | dmenu appears on the given Xinerama screen. | ||
| 58 | .TP | ||
| 54 | .BI \-p " prompt" | 59 | .BI \-p " prompt" |
| 55 | defines the prompt to be displayed to the left of the input field. | 60 | defines the prompt to be displayed to the left of the input field. |
| 56 | .TP | 61 | .TP |
| @@ -63,6 +63,52 @@ static Window root, win; | |||
| 63 | 63 | ||
| 64 | static int (*fstrncmp)(const char *, const char *, size_t) = strncmp; | 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 | void | 112 | void |
| 67 | appenditem(Item *item, Item **list, Item **last) { | 113 | appenditem(Item *item, Item **list, Item **last) { |
| 68 | if(!*last) | 114 | if(!*last) |
| @@ -490,53 +536,7 @@ setup(void) { | |||
| 490 | 536 | ||
| 491 | void | 537 | void |
| 492 | usage(void) { | 538 | usage(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 | |||
| 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 | } | ||
