dwm-meillo

changeset 137:77922a389fa8

simplified main.c, switching back to single urxvt usage
author arg@10ksloc.org
date Fri, 21 Jul 2006 14:11:38 +0200
parents 3a9caa6d565b
children c1185dc7a36e
files event.c main.c
diffstat 2 files changed, 14 insertions(+), 28 deletions(-) [+]
line diff
     1.1 --- a/event.c	Fri Jul 21 11:54:14 2006 +0200
     1.2 +++ b/event.c	Fri Jul 21 14:11:38 2006 +0200
     1.3 @@ -23,7 +23,7 @@
     1.4  const char *browse[] = { "firefox", NULL };
     1.5  const char *gimp[] = { "gimp", NULL };
     1.6  const char *term[] = { 
     1.7 -	"urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white",
     1.8 +	"urxvt", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white",
     1.9  	"-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL
    1.10  };
    1.11  const char *xlock[] = { "xlock", NULL };
     2.1 --- a/main.c	Fri Jul 21 11:54:14 2006 +0200
     2.2 +++ b/main.c	Fri Jul 21 14:11:38 2006 +0200
     2.3 @@ -166,22 +166,17 @@
     2.4  	int i, n;
     2.5  	unsigned int mask;
     2.6  	fd_set rd;
     2.7 -	Bool readstdin = True;
     2.8 +	Bool readin = True;
     2.9  	Window w;
    2.10  	XEvent ev;
    2.11  	XSetWindowAttributes wa;
    2.12  
    2.13 -	for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
    2.14 -		switch (argv[i][1]) {
    2.15 -		default:
    2.16 -			eprint("usage: dwm [-v]\n");
    2.17 -			break;
    2.18 -		case 'v':
    2.19 -			fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
    2.20 -			exit(EXIT_SUCCESS);
    2.21 -			break;
    2.22 -		}
    2.23 +	if(argc == 2 && !strncmp("-v", argv[1], 3)) {
    2.24 +		fputs("dwm-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
    2.25 +		exit(EXIT_SUCCESS);
    2.26  	}
    2.27 +	else if(argc != 1)
    2.28 +		eprint("usage: dwm [-v]\n");
    2.29  
    2.30  	dpy = XOpenDisplay(0);
    2.31  	if(!dpy)
    2.32 @@ -256,10 +251,9 @@
    2.33  	scan();
    2.34  
    2.35  	/* main event loop, reads status text from stdin as well */
    2.36 -Mainloop:
    2.37  	while(running) {
    2.38  		FD_ZERO(&rd);
    2.39 -		if(readstdin)
    2.40 +		if(readin)
    2.41  			FD_SET(STDIN_FILENO, &rd);
    2.42  		FD_SET(ConnectionNumber(dpy), &rd);
    2.43  
    2.44 @@ -276,20 +270,12 @@
    2.45  						(handler[ev.type])(&ev); /* call handler */
    2.46  				}
    2.47  			}
    2.48 -			if(readstdin && FD_ISSET(STDIN_FILENO, &rd)) {
    2.49 -				i = n = 0;
    2.50 -				for(;;) {
    2.51 -					if((i = getchar()) == EOF) {
    2.52 -						/* broken pipe/end of producer */
    2.53 -						readstdin = False;
    2.54 -						strcpy(stext, "broken pipe");
    2.55 -						goto Mainloop;
    2.56 -					}
    2.57 -					if(i == '\n' || n >= sizeof(stext) - 1)
    2.58 -						break;
    2.59 -					stext[n++] = i;
    2.60 -				}
    2.61 -				stext[n] = 0;
    2.62 +			if(readin && FD_ISSET(STDIN_FILENO, &rd)) {
    2.63 +				readin = NULL != fgets(stext, sizeof(stext), stdin);
    2.64 +				if(readin)
    2.65 +					stext[strlen(stext) - 1] = 0;
    2.66 +				else 
    2.67 +					strcpy(stext, "broken pipe");
    2.68  				drawstatus();
    2.69  			}
    2.70  		}