X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=main.c;h=9ea09bff66f6787ae91b06c24655bf472af4e06d;hb=a2d56f6dcef7adb1a85951871cb51a052709241a;hp=86d72fadb42ad765509291fd73899b9e4d9a2926;hpb=0cf3ba0eab1e3b05515907b29fbb739321a7cbed;p=dwm.git diff --git a/main.c b/main.c index 86d72fa..9ea09bf 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,6 @@ */ #include "dwm.h" - #include #include #include @@ -15,7 +14,6 @@ #include #include - /* static */ static int (*xerrorxlib)(Display *, XErrorEvent *); @@ -87,6 +85,7 @@ xerrorstart(Display *dsply, XErrorEvent *ee) char stext[1024]; int tsel = DEFTAG; int screen, sx, sy, sw, sh, bx, by, bw, bh, mw; +unsigned int ntags; Atom wmatom[WMLast], netatom[NetLast]; Bool running = True; Bool issel = True; @@ -165,6 +164,7 @@ main(int argc, char *argv[]) int i; unsigned int mask; fd_set rd; + Bool readin = True; Window w; XEvent ev; XSetWindowAttributes wa; @@ -211,6 +211,8 @@ main(int argc, char *argv[]) grabkeys(); + for(ntags = 0; tags[ntags]; ntags++); + /* style */ dc.bg = getcolor(BGCOLOR); dc.fg = getcolor(FGCOLOR); @@ -251,7 +253,8 @@ main(int argc, char *argv[]) /* main event loop, reads status text from stdin as well */ while(running) { FD_ZERO(&rd); - FD_SET(STDIN_FILENO, &rd); + if(readin) + FD_SET(STDIN_FILENO, &rd); FD_SET(ConnectionNumber(dpy), &rd); i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0); @@ -267,11 +270,12 @@ main(int argc, char *argv[]) (handler[ev.type])(&ev); /* call handler */ } } - if(FD_ISSET(STDIN_FILENO, &rd)) { - if(!fgets(stext, sizeof(stext), stdin)) - break; - else + if(readin && FD_ISSET(STDIN_FILENO, &rd)) { + readin = NULL != fgets(stext, sizeof(stext), stdin); + if(readin) stext[strlen(stext) - 1] = 0; + else + strcpy(stext, "broken pipe"); drawstatus(); } }