dwm-meillo

diff wm.c @ 31:386649deb651

before leaning things up
author Anselm R. Garbe <garbeam@wmii.de>
date Thu, 13 Jul 2006 01:04:38 +0200
parents 2e0fb4130bfb
children 082c75b937b5
line diff
     1.1 --- a/wm.c	Wed Jul 12 17:50:31 2006 +0200
     1.2 +++ b/wm.c	Thu Jul 13 01:04:38 2006 +0200
     1.3 @@ -18,15 +18,39 @@
     1.4  
     1.5  #include "wm.h"
     1.6  
     1.7 +/********** CUSTOMIZE **********/
     1.8 +
     1.9 +char *tags[TLast] = {
    1.10 +	[Tscratch] = "scratch",
    1.11 +	[Tdev] = "dev",
    1.12 +	[Tirc] = "irc",
    1.13 +	[Twww] = "www",
    1.14 +	[Twork] = "work",
    1.15 +};
    1.16 +
    1.17 +/* commands */
    1.18 +static char *cmdwallpaper[] = {
    1.19 +	"feh", "--bg-scale", "/home/garbeam/wallpaper/bg.jpg", NULL
    1.20 +};
    1.21 +
    1.22 +static char *cmdstatus[] = {
    1.23 +	"sh", "-c", "echo -n `date '+%Y-%m-%d %H:%M'`" 
    1.24 +	" `uptime | sed 's/.*://; s/,//g'`"
    1.25 +	" `acpi | awk '{print $4}' | sed 's/,//'`", NULL
    1.26 +};
    1.27 +
    1.28 +/********** CUSTOMIZE **********/
    1.29 +
    1.30  /* X structs */
    1.31  Display *dpy;
    1.32  Window root, barwin;
    1.33  Atom wm_atom[WMLast], net_atom[NetLast];
    1.34  Cursor cursor[CurLast];
    1.35  Bool running = True;
    1.36 -Bool sel_screen;
    1.37 +Bool issel;
    1.38  
    1.39 -char statustext[1024], tag[256];
    1.40 +char stext[1024];
    1.41 +int tsel = Tdev; /* default tag */
    1.42  int screen, sx, sy, sw, sh, bx, by, bw, bh;
    1.43  
    1.44  Brush brush = {0};
    1.45 @@ -34,21 +58,12 @@
    1.46  Client *stack = NULL;
    1.47  
    1.48  static Bool other_wm_running;
    1.49 -static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
    1.50 +static const char version[] =
    1.51 +	"gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
    1.52  static int (*x_error_handler) (Display *, XErrorEvent *);
    1.53  
    1.54 -static const char *status[] = {
    1.55 -	"sh", "-c", "echo -n `date '+%Y-%m-%d %H:%M'`" 
    1.56 -	" `uptime | sed 's/.*://; s/,//g'`"
    1.57 -	" `acpi | awk '{print $4}' | sed 's/,//'`", 0
    1.58 -};
    1.59 -
    1.60  static void
    1.61 -usage()
    1.62 -{
    1.63 -	fputs("usage: gridwm [-v]\n", stderr);
    1.64 -	exit(1);
    1.65 -}
    1.66 +usage() {	error("usage: gridwm [-v]\n"); }
    1.67  
    1.68  static void
    1.69  scan_wins()
    1.70 @@ -230,10 +245,11 @@
    1.71  	if(other_wm_running)
    1.72  		error("gridwm: another window manager is already running\n");
    1.73  
    1.74 +	spawn(dpy, cmdwallpaper);
    1.75  	sx = sy = 0;
    1.76  	sw = DisplayWidth(dpy, screen);
    1.77  	sh = DisplayHeight(dpy, screen);
    1.78 -	sel_screen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
    1.79 +	issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
    1.80  
    1.81  	XSetErrorHandler(0);
    1.82  	x_error_handler = XSetErrorHandler(error_handler);
    1.83 @@ -275,7 +291,7 @@
    1.84  	brush.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
    1.85  	brush.gc = XCreateGC(dpy, root, 0, 0);
    1.86  
    1.87 -	pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
    1.88 +	pipe_spawn(stext, sizeof(stext), dpy, cmdstatus);
    1.89  	draw_bar();
    1.90  
    1.91  	wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
    1.92 @@ -283,6 +299,7 @@
    1.93  	wa.cursor = cursor[CurNormal];
    1.94  	XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
    1.95  
    1.96 +	arrange = grid;
    1.97  	scan_wins();
    1.98  
    1.99  	while(running) {
   1.100 @@ -298,7 +315,7 @@
   1.101  		if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0)
   1.102  			continue;
   1.103  		else if(errno != EINTR) {
   1.104 -			pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status);
   1.105 +			pipe_spawn(stext, sizeof(stext), dpy, cmdstatus);
   1.106  			draw_bar();
   1.107  		}
   1.108  	}