aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c52
1 files changed, 36 insertions, 16 deletions
diff --git a/main.c b/main.c
index 170a3e0..27b28af 100644
--- a/main.c
+++ b/main.c
@@ -283,19 +283,41 @@ DC dc = {0};
283 283
284int 284int
285main(int argc, char *argv[]) { 285main(int argc, char *argv[]) {
286 char *font = FONT;
286 char *maxname; 287 char *maxname;
288 char *normbg = NORMBGCOLOR;
289 char *normfg = NORMFGCOLOR;
290 char *selbg = SELBGCOLOR;
291 char *selfg = SELFGCOLOR;
287 fd_set rd; 292 fd_set rd;
293 int i;
288 struct timeval timeout; 294 struct timeval timeout;
289 Item *i; 295 Item *itm;
290 XEvent ev; 296 XEvent ev;
291 XSetWindowAttributes wa; 297 XSetWindowAttributes wa;
292 298
293 if(argc == 2 && !strncmp("-v", argv[1], 3)) { 299 timeout.tv_usec = 0;
294 fputs("dmenu-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout); 300 timeout.tv_sec = 3;
295 exit(EXIT_SUCCESS); 301 /* command line args */
296 } 302 for(i = 1; i < argc; i++)
297 else if(argc != 1) 303 if(!strncmp(argv[i], "-font", 6))
298 eprint("usage: dmenu [-v]\n"); 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 dpy = XOpenDisplay(0); 322 dpy = XOpenDisplay(0);
301 if(!dpy) 323 if(!dpy)
@@ -312,8 +334,6 @@ main(int argc, char *argv[]) {
312 GrabModeAsync, CurrentTime) != GrabSuccess) 334 GrabModeAsync, CurrentTime) != GrabSuccess)
313 usleep(1000); 335 usleep(1000);
314 336
315 timeout.tv_usec = 0;
316 timeout.tv_sec = STDIN_TIMEOUT;
317 FD_ZERO(&rd); 337 FD_ZERO(&rd);
318 FD_SET(STDIN_FILENO, &rd); 338 FD_SET(STDIN_FILENO, &rd);
319 if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1) 339 if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, &timeout) < 1)
@@ -321,11 +341,11 @@ main(int argc, char *argv[]) {
321 maxname = readstdin(); 341 maxname = readstdin();
322 342
323 /* style */ 343 /* style */
324 dc.sel[ColBG] = getcolor(SELBGCOLOR); 344 dc.sel[ColBG] = getcolor(selbg);
325 dc.sel[ColFG] = getcolor(SELFGCOLOR); 345 dc.sel[ColFG] = getcolor(selfg);
326 dc.norm[ColBG] = getcolor(NORMBGCOLOR); 346 dc.norm[ColBG] = getcolor(normbg);
327 dc.norm[ColFG] = getcolor(NORMFGCOLOR); 347 dc.norm[ColFG] = getcolor(normfg);
328 setfont(FONT); 348 setfont(font);
329 349
330 wa.override_redirect = 1; 350 wa.override_redirect = 1;
331 wa.background_pixmap = ParentRelative; 351 wa.background_pixmap = ParentRelative;
@@ -373,10 +393,10 @@ main(int argc, char *argv[]) {
373 } 393 }
374 394
375 while(allitems) { 395 while(allitems) {
376 i = allitems->next; 396 itm = allitems->next;
377 free(allitems->text); 397 free(allitems->text);
378 free(allitems); 398 free(allitems);
379 allitems = i; 399 allitems = itm;
380 } 400 }
381 if(dc.font.set) 401 if(dc.font.set)
382 XFreeFontSet(dpy, dc.font.set); 402 XFreeFontSet(dpy, dc.font.set);