int main(int argc, char *argv[]) { Bool fast = False; int i; if(strcmp(argv[0], "dmenu_run") == 0) /* called as `dmenu_run' */ dmenurun = True; for(i = 1; i < argc; i++) /* these options take no arguments */ if(!strcmp(argv[i], "-v")) { /* prints version information */ puts("dmenu-"VERSION", © 2006-2014 dmenu engineers, see LICENSE for details"); exit(EXIT_SUCCESS); } else if(!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ topbar = False; else if(!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ fast = True; else if(!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ fstrncmp = strncasecmp; fstrstr = cistrstr; } else if(i+1 == argc) usage(); /* these options take one argument */ else if(!strcmp(argv[i], "-l")) /* number of lines in vertical list */ lines = atoi(argv[++i]); else if(!strcmp(argv[i], "-m")) mon = atoi(argv[++i]); else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ prompt = argv[++i]; else if(!strcmp(argv[i], "-fn")) /* font or font set */ font = argv[++i]; else if(!strcmp(argv[i], "-nb")) /* normal background color */ normbgcolor = argv[++i]; else if(!strcmp(argv[i], "-nf")) /* normal foreground color */ normfgcolor = argv[++i]; else if(!strcmp(argv[i], "-sb")) /* selected background color */ selbgcolor = argv[++i]; else if(!strcmp(argv[i], "-sf")) /* selected foreground color */ selfgcolor = argv[++i]; else usage(); dc = initdc(); initfont(dc, font); if(fast) { grabkeyboard(); readstdin(); } else { readstdin(); grabkeyboard(); } setup(); run(); return 1; /* unreachable */ }
int main(int argc, char **argv) { for (int i = 1; i < argc; i++) { if (!strcmp(argv[i], "-v")) { puts("vis-menu " VERSION); exit(EXIT_SUCCESS); } else if (!strcmp(argv[i], "-i")) { fstrncmp = strncasecmp; } else if (!strcmp(argv[i], "-t")) { barpos = +1; } else if (!strcmp(argv[i], "-b")) { barpos = -1; } else if (argv[i][0] != '-') { strncpy(text, argv[i], sizeof(text)-1); cursor = strlen(text); } else if (i + 1 == argc) { usage(); } else if (!strcmp(argv[i], "-p")) { prompt = argv[++i]; if (prompt && !prompt[0]) prompt = NULL; } else if (!strcmp(argv[i], "-l")) { lines = atoi(argv[++i]); } else { usage(); } } readstdin(); setup(); int status = run(); cleanup(); return status; }
int main(int argc, char **argv) { int i; for(i=0; i<argc; i++) /* single flags */ if(!strcmp(argv[i], "-v")) { puts("slmenu, © 2011 slmenu engineers, see LICENSE for details"); exit(EXIT_SUCCESS); } else if(!strcmp(argv[i], "-i")) fstrncmp = strncasecmp; else if(!strcmp(argv[i], "-t")) barpos=1; else if(!strcmp(argv[i], "-b")) barpos=-1; /* double flags */ else if(!strcmp(argv[i], "-p")) prompt=argv[++i]; else if(!strcmp(argv[i], "-l")) lines = atoi(argv[++i]); readstdin(); setup(); i = run(); cleanup(); return i; }
int main(int argc, char *argv[]) { Bool fast = False; int i; for(i = 1; i < argc; i++) /* these options take no arguments */ if(!strcmp(argv[i], "-v")) { /* prints version information */ puts("dmenu-"VERSION", © 2006-2012 dmenu engineers, see LICENSE for details"); exit(EXIT_SUCCESS); } else if(!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ topbar = False; else if(!strcmp(argv[i], "-q")) quiet = True; else if(!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ fast = True; else if(!strcmp(argv[i], "-z")) /* enable fuzzy matching */ fuzzy = True; else if(!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ fstrncmp = strncasecmp; fstrstr = cistrstr; fstrchr = strchri; } else if(i+1 == argc) usage(); /* these options take one argument */ else if(!strcmp(argv[i], "-x")) xoffset = atoi(argv[++i]); else if(!strcmp(argv[i], "-y")) yoffset = atoi(argv[++i]); else if(!strcmp(argv[i], "-w")) width = atoi(argv[++i]); else if(!strcmp(argv[i], "-l")) /* number of lines in vertical list */ lines = atoi(argv[++i]); else if(!strcmp(argv[i], "-h")) /* minimum height of single line */ line_height = atoi(argv[++i]); else if(!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ prompt = argv[++i]; else if(!strcmp(argv[i], "-fn")) /* font or font set */ font = argv[++i]; else if(!strcmp(argv[i], "-nb")) /* normal background color */ normbgcolor = argv[++i]; else if(!strcmp(argv[i], "-nf")) /* normal foreground color */ normfgcolor = argv[++i]; else if(!strcmp(argv[i], "-sb")) /* selected background color */ selbgcolor = argv[++i]; else if(!strcmp(argv[i], "-sf")) /* selected foreground color */ selfgcolor = argv[++i]; else usage(); dc = initdc(); initfont(dc, font ? font : DEFFONT); normcol = initcolor(dc, normfgcolor, normbgcolor); selcol = initcolor(dc, selfgcolor, selbgcolor); if(fast) { grabkeyboard(); readstdin(); } else { readstdin(); grabkeyboard(); } setup(); run(); cleanup(); return ret; }
int main(int argc, char *argv[]) { bool fast = false; int i; for (i = 1; i < argc; i++) /* these options take no arguments */ if (!strcmp(argv[i], "-v")) { /* prints version information */ puts("dmenu-"VERSION); exit(0); } else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ topbar = false; else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ fast = true; else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ fstrncmp = strncasecmp; fstrstr = cistrstr; } else if (i + 1 == argc) usage(); /* these options take one argument */ else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ lines = atoi(argv[++i]); else if (!strcmp(argv[i], "-m")) mon = atoi(argv[++i]); else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ prompt = argv[++i]; else if (!strcmp(argv[i], "-fn")) /* font or font set */ fonts[0] = argv[++i]; else if (!strcmp(argv[i], "-nb")) /* normal background color */ normbgcolor = argv[++i]; else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ normfgcolor = argv[++i]; else if (!strcmp(argv[i], "-sb")) /* selected background color */ selbgcolor = argv[++i]; else if (!strcmp(argv[i], "-sf")) /* selected foreground color */ selfgcolor = argv[++i]; else usage(); if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fputs("warning: no locale support\n", stderr); if (!(dpy = XOpenDisplay(NULL))) die("cannot open display\n"); screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); drw = drw_create(dpy, screen, root, sw, sh); drw_load_fonts(drw, fonts, LENGTH(fonts)); if (!drw->fontcount) die("no fonts could be loaded.\n"); drw_setscheme(drw, &scheme[SchemeNorm]); if (fast) { grabkeyboard(); readstdin(); } else { readstdin(); grabkeyboard(); } setup(); run(); return 1; /* unreachable */ }
int main(int argc, char *argv[]) { XWindowAttributes wa; int i, fast = 0; for (i = 1; i < argc; i++) /* these options take no arguments */ if (!strcmp(argv[i], "-v")) { /* prints version information */ puts("dmenu-"VERSION); exit(0); } else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */ topbar = 0; else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */ fast = 1; else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ fstrncmp = strncasecmp; fstrstr = cistrstr; } else if (i + 1 == argc) usage(); /* these options take one argument */ else if (!strcmp(argv[i], "-H")) histfile = argv[++i]; else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ lines = atoi(argv[++i]); else if (!strcmp(argv[i], "-m")) mon = atoi(argv[++i]); else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */ prompt = argv[++i]; else if (!strcmp(argv[i], "-fn")) /* font or font set */ fonts[0] = argv[++i]; else if (!strcmp(argv[i], "-nb")) /* normal background color */ colors[SchemeNorm][ColBg] = argv[++i]; else if (!strcmp(argv[i], "-nf")) /* normal foreground color */ colors[SchemeNorm][ColFg] = argv[++i]; else if (!strcmp(argv[i], "-sb")) /* selected background color */ colors[SchemeSel][ColBg] = argv[++i]; else if (!strcmp(argv[i], "-sf")) /* selected foreground color */ colors[SchemeSel][ColFg] = argv[++i]; else if (!strcmp(argv[i], "-w")) /* embedding window id */ embed = argv[++i]; else usage(); if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fputs("warning: no locale support\n", stderr); if (!(dpy = XOpenDisplay(NULL))) die("cannot open display"); screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); if (!embed || !(parentwin = strtol(embed, NULL, 0))) parentwin = root; if (!XGetWindowAttributes(dpy, parentwin, &wa)) die("could not get embedding window attributes: 0x%lx", parentwin); drw = drw_create(dpy, screen, root, wa.width, wa.height); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); lrpad = drw->fonts->h; loadhistory(); if (fast) { grabkeyboard(); readstdin(); } else { readstdin(); grabkeyboard(); } setup(); run(); return 1; /* unreachable */ }
int main(int argc, char *argv[]) { int i; progname = "dmenu"; for(i = 1; i < argc; i++) /* single flags */ if(!strcmp(argv[i], "-v") || !strcmp(argv[1], "--version")) { fputs("dmenu-"VERSION", © 2006-2011 dmenu engineers, see LICENSE for details\n", stdout); exit(EXIT_SUCCESS); } else if(!strcmp(argv[i], "-b") || !strcmp(argv[i], "--bottom")) topbar = False; else if(!strcmp(argv[i], "-e") || !strcmp(argv[i], "--echo")) message = True; else if(!strcmp(argv[i], "-ec") || !strcmp(argv[i], "--echo-centre")) message = True, messageposition = CENTRE; else if(!strcmp(argv[i], "-er") || !strcmp(argv[i], "--echo-right")) message = True, messageposition = RIGHT; else if(!strcmp(argv[i], "-i") || !strcmp(argv[i], "--insensitive")) fstrncmp = strncasecmp; else if(!strcmp(argv[i], "-r") || !strcmp(argv[i], "--return-early")) returnearly = True; else if(i==argc-1) usage(); /* opts that need 1 arg */ else if(!strcmp(argv[i], "-et") || !strcmp(argv[i], "--echo-timeout")) timeout = atoi(argv[++i]); else if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--height")) height = atoi(argv[++i]); else if(!strcmp(argv[i], "-l") || !strcmp(argv[i], "--lines")) lines = atoi(argv[++i]); else if(!strcmp(argv[i], "-m") || !strcmp(argv[i], "--monitor")) monitor = atoi(argv[++i]); else if(!strcmp(argv[i], "-p") || !strcmp(argv[i], "--prompt")) prompt = argv[++i]; else if(!strcmp(argv[i], "-po") || !strcmp(argv[i], "--prompt-only")) prompt = argv[++i], nostdin = True; else if(!strcmp(argv[i], "-fn") || !strcmp(argv[i], "--font-name")) font = argv[++i]; else if(!strcmp(argv[i], "-nb") || !strcmp(argv[i], "--normal-background")) normbgcolor = argv[++i]; else if(!strcmp(argv[i], "-nf") || !strcmp(argv[i], "--normal-foreground")) normfgcolor = argv[++i]; else if(!strcmp(argv[i], "-sb") || !strcmp(argv[i], "--selected-background")) selbgcolor = argv[++i]; else if(!strcmp(argv[i], "-sf") || !strcmp(argv[i], "--selected-foreground")) selfgcolor = argv[++i]; else usage(); if(message) { signal(SIGALRM, alarmhandler); alarm(timeout); } dc = initdc(); initfont(dc, font); if(!nostdin) { readstdin(); } setup(); run(); return EXIT_FAILURE; /* should not reach */ }