*/
#include "dwm.h"
-
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xatom.h>
#include <X11/Xproto.h>
-
/* static */
static int (*xerrorxlib)(Display *, XErrorEvent *);
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;
int i;
unsigned int mask;
fd_set rd;
+ Bool readin = True;
Window w;
XEvent ev;
XSetWindowAttributes wa;
grabkeys();
+ for(ntags = 0; tags[ntags]; ntags++);
+
/* style */
dc.bg = getcolor(BGCOLOR);
dc.fg = getcolor(FGCOLOR);
/* 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);
(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();
}
}