diff options
Diffstat (limited to 'wm.c')
| -rw-r--r-- | wm.c | 51 |
1 files changed, 34 insertions, 17 deletions
| @@ -18,15 +18,39 @@ | |||
| 18 | 18 | ||
| 19 | #include "wm.h" | 19 | #include "wm.h" |
| 20 | 20 | ||
| 21 | /********** CUSTOMIZE **********/ | ||
| 22 | |||
| 23 | char *tags[TLast] = { | ||
| 24 | [Tscratch] = "scratch", | ||
| 25 | [Tdev] = "dev", | ||
| 26 | [Tirc] = "irc", | ||
| 27 | [Twww] = "www", | ||
| 28 | [Twork] = "work", | ||
| 29 | }; | ||
| 30 | |||
| 31 | /* commands */ | ||
| 32 | static char *cmdwallpaper[] = { | ||
| 33 | "feh", "--bg-scale", "/home/garbeam/wallpaper/bg.jpg", NULL | ||
| 34 | }; | ||
| 35 | |||
| 36 | static char *cmdstatus[] = { | ||
| 37 | "sh", "-c", "echo -n `date '+%Y-%m-%d %H:%M'`" | ||
| 38 | " `uptime | sed 's/.*://; s/,//g'`" | ||
| 39 | " `acpi | awk '{print $4}' | sed 's/,//'`", NULL | ||
| 40 | }; | ||
| 41 | |||
| 42 | /********** CUSTOMIZE **********/ | ||
| 43 | |||
| 21 | /* X structs */ | 44 | /* X structs */ |
| 22 | Display *dpy; | 45 | Display *dpy; |
| 23 | Window root, barwin; | 46 | Window root, barwin; |
| 24 | Atom wm_atom[WMLast], net_atom[NetLast]; | 47 | Atom wm_atom[WMLast], net_atom[NetLast]; |
| 25 | Cursor cursor[CurLast]; | 48 | Cursor cursor[CurLast]; |
| 26 | Bool running = True; | 49 | Bool running = True; |
| 27 | Bool sel_screen; | 50 | Bool issel; |
| 28 | 51 | ||
| 29 | char statustext[1024], tag[256]; | 52 | char stext[1024]; |
| 53 | int tsel = Tdev; /* default tag */ | ||
| 30 | int screen, sx, sy, sw, sh, bx, by, bw, bh; | 54 | int screen, sx, sy, sw, sh, bx, by, bw, bh; |
| 31 | 55 | ||
| 32 | Brush brush = {0}; | 56 | Brush brush = {0}; |
| @@ -34,21 +58,12 @@ Client *clients = NULL; | |||
| 34 | Client *stack = NULL; | 58 | Client *stack = NULL; |
| 35 | 59 | ||
| 36 | static Bool other_wm_running; | 60 | static Bool other_wm_running; |
| 37 | static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; | 61 | static const char version[] = |
| 62 | "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; | ||
| 38 | static int (*x_error_handler) (Display *, XErrorEvent *); | 63 | static int (*x_error_handler) (Display *, XErrorEvent *); |
| 39 | 64 | ||
| 40 | static const char *status[] = { | ||
| 41 | "sh", "-c", "echo -n `date '+%Y-%m-%d %H:%M'`" | ||
| 42 | " `uptime | sed 's/.*://; s/,//g'`" | ||
| 43 | " `acpi | awk '{print $4}' | sed 's/,//'`", 0 | ||
| 44 | }; | ||
| 45 | |||
| 46 | static void | 65 | static void |
| 47 | usage() | 66 | usage() { error("usage: gridwm [-v]\n"); } |
| 48 | { | ||
| 49 | fputs("usage: gridwm [-v]\n", stderr); | ||
| 50 | exit(1); | ||
| 51 | } | ||
| 52 | 67 | ||
| 53 | static void | 68 | static void |
| 54 | scan_wins() | 69 | scan_wins() |
| @@ -230,10 +245,11 @@ main(int argc, char *argv[]) | |||
| 230 | if(other_wm_running) | 245 | if(other_wm_running) |
| 231 | error("gridwm: another window manager is already running\n"); | 246 | error("gridwm: another window manager is already running\n"); |
| 232 | 247 | ||
| 248 | spawn(dpy, cmdwallpaper); | ||
| 233 | sx = sy = 0; | 249 | sx = sy = 0; |
| 234 | sw = DisplayWidth(dpy, screen); | 250 | sw = DisplayWidth(dpy, screen); |
| 235 | sh = DisplayHeight(dpy, screen); | 251 | sh = DisplayHeight(dpy, screen); |
| 236 | sel_screen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); | 252 | issel = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask); |
| 237 | 253 | ||
| 238 | XSetErrorHandler(0); | 254 | XSetErrorHandler(0); |
| 239 | x_error_handler = XSetErrorHandler(error_handler); | 255 | x_error_handler = XSetErrorHandler(error_handler); |
| @@ -275,7 +291,7 @@ main(int argc, char *argv[]) | |||
| 275 | brush.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); | 291 | brush.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); |
| 276 | brush.gc = XCreateGC(dpy, root, 0, 0); | 292 | brush.gc = XCreateGC(dpy, root, 0, 0); |
| 277 | 293 | ||
| 278 | pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status); | 294 | pipe_spawn(stext, sizeof(stext), dpy, cmdstatus); |
| 279 | draw_bar(); | 295 | draw_bar(); |
| 280 | 296 | ||
| 281 | wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ | 297 | wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ |
| @@ -283,6 +299,7 @@ main(int argc, char *argv[]) | |||
| 283 | wa.cursor = cursor[CurNormal]; | 299 | wa.cursor = cursor[CurNormal]; |
| 284 | XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); | 300 | XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa); |
| 285 | 301 | ||
| 302 | arrange = grid; | ||
| 286 | scan_wins(); | 303 | scan_wins(); |
| 287 | 304 | ||
| 288 | while(running) { | 305 | while(running) { |
| @@ -298,7 +315,7 @@ main(int argc, char *argv[]) | |||
| 298 | if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0) | 315 | if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0) |
| 299 | continue; | 316 | continue; |
| 300 | else if(errno != EINTR) { | 317 | else if(errno != EINTR) { |
| 301 | pipe_spawn(statustext, sizeof(statustext), dpy, (char **)status); | 318 | pipe_spawn(stext, sizeof(stext), dpy, cmdstatus); |
| 302 | draw_bar(); | 319 | draw_bar(); |
| 303 | } | 320 | } |
| 304 | } | 321 | } |
