wm.c
changeset 16 359b6e563b95
parent 14 5c078b66347b
child 21 3ef108a5ca0a
equal deleted inserted replaced
15:00d4d52b231f 16:359b6e563b95
    25 Cursor cursor[CurLast];
    25 Cursor cursor[CurLast];
    26 XRectangle rect, barrect;
    26 XRectangle rect, barrect;
    27 Bool running = True;
    27 Bool running = True;
    28 Bool sel_screen;
    28 Bool sel_screen;
    29 
    29 
    30 char *bartext, tag[256];
    30 char statustext[1024], tag[256];
    31 int screen;
    31 int screen;
    32 
    32 
    33 Brush brush = {0};
    33 Brush brush = {0};
    34 Client *clients = NULL;
    34 Client *clients = NULL;
    35 Client *stack = NULL;
    35 Client *stack = NULL;
    36 
    36 
    37 static Bool other_wm_running;
    37 static Bool other_wm_running;
    38 static char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
    38 static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
    39 static int (*x_error_handler) (Display *, XErrorEvent *);
    39 static int (*x_error_handler) (Display *, XErrorEvent *);
       
    40 
       
    41 static const char *status[] = {
       
    42 	"sh", "-c", "echo -n `date '+%Y/%m/%d %H:%M'`" 
       
    43 	" `uptime | sed 's/.*://; s/,//g'`"
       
    44 	" `acpi | awk '{print $4}' | sed 's/,//'`", 0
       
    45 };
    40 
    46 
    41 static void
    47 static void
    42 usage()
    48 usage()
    43 {
    49 {
    44 	fputs("usage: gridwm [-v]\n", stderr);
    50 	fputs("usage: gridwm [-v]\n", stderr);
   256 	barrect.y = rect.height - barrect.height;
   262 	barrect.y = rect.height - barrect.height;
   257 	barwin = XCreateWindow(dpy, root, barrect.x, barrect.y,
   263 	barwin = XCreateWindow(dpy, root, barrect.x, barrect.y,
   258 			barrect.width, barrect.height, 0, DefaultDepth(dpy, screen),
   264 			barrect.width, barrect.height, 0, DefaultDepth(dpy, screen),
   259 			CopyFromParent, DefaultVisual(dpy, screen),
   265 			CopyFromParent, DefaultVisual(dpy, screen),
   260 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
   266 			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
   261 	bartext = NULL;
       
   262 	XDefineCursor(dpy, barwin, cursor[CurNormal]);
   267 	XDefineCursor(dpy, barwin, cursor[CurNormal]);
   263 	XMapRaised(dpy, barwin);
   268 	XMapRaised(dpy, barwin);
       
   269 	pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
   264 	draw_bar();
   270 	draw_bar();
   265 
   271 
   266 	wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
   272 	wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
   267 					| LeaveWindowMask;
   273 					| LeaveWindowMask;
   268 	wa.cursor = cursor[CurNormal];
   274 	wa.cursor = cursor[CurNormal];
   280 		FD_ZERO(&fds);
   286 		FD_ZERO(&fds);
   281 		FD_SET(ConnectionNumber(dpy), &fds);
   287 		FD_SET(ConnectionNumber(dpy), &fds);
   282 		t = timeout;
   288 		t = timeout;
   283 		if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0)
   289 		if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0)
   284 			continue;
   290 			continue;
   285 		else if(errno != EINTR)
   291 		else if(errno != EINTR) {
       
   292 			pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
   286 			draw_bar();
   293 			draw_bar();
       
   294 		}
   287 	}
   295 	}
   288 
   296 
   289 	cleanup();
   297 	cleanup();
   290 	XCloseDisplay(dpy);
   298 	XCloseDisplay(dpy);
   291 
   299