summaryrefslogtreecommitdiffstats
path: root/wm.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-13 01:04:38 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-13 01:04:38 +0200
commitda2bbd371c522d63d737d43a127601a3fdbcb9d8 (patch)
treefe7f5874dc09c446d3da38f15930c5f6ae523c13 /wm.c
parentnew stuff, fixed several issues (diff)
downloaddwm-da2bbd371c522d63d737d43a127601a3fdbcb9d8.tar.gz
dwm-da2bbd371c522d63d737d43a127601a3fdbcb9d8.zip
before leaning things up
Diffstat (limited to '')
-rw-r--r--wm.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/wm.c b/wm.c
index ed40a8b..1c9e1f9 100644
--- a/wm.c
+++ b/wm.c
@@ -18,15 +18,39 @@
18 18
19#include "wm.h" 19#include "wm.h"
20 20
21/********** CUSTOMIZE **********/
22
23char *tags[TLast] = {
24 [Tscratch] = "scratch",
25 [Tdev] = "dev",
26 [Tirc] = "irc",
27 [Twww] = "www",
28 [Twork] = "work",
29};
30
31/* commands */
32static char *cmdwallpaper[] = {
33 "feh", "--bg-scale", "/home/garbeam/wallpaper/bg.jpg", NULL
34};
35
36static 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 */
22Display *dpy; 45Display *dpy;
23Window root, barwin; 46Window root, barwin;
24Atom wm_atom[WMLast], net_atom[NetLast]; 47Atom wm_atom[WMLast], net_atom[NetLast];
25Cursor cursor[CurLast]; 48Cursor cursor[CurLast];
26Bool running = True; 49Bool running = True;
27Bool sel_screen; 50Bool issel;
28 51
29char statustext[1024], tag[256]; 52char stext[1024];
53int tsel = Tdev; /* default tag */
30int screen, sx, sy, sw, sh, bx, by, bw, bh; 54int screen, sx, sy, sw, sh, bx, by, bw, bh;
31 55
32Brush brush = {0}; 56Brush brush = {0};
@@ -34,21 +58,12 @@ Client *clients = NULL;
34Client *stack = NULL; 58Client *stack = NULL;
35 59
36static Bool other_wm_running; 60static Bool other_wm_running;
37static const char version[] = "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 61static const char version[] =
62 "gridwm - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
38static int (*x_error_handler) (Display *, XErrorEvent *); 63static int (*x_error_handler) (Display *, XErrorEvent *);
39 64
40static 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
46static void 65static void
47usage() 66usage() { error("usage: gridwm [-v]\n"); }
48{
49 fputs("usage: gridwm [-v]\n", stderr);
50 exit(1);
51}
52 67
53static void 68static void
54scan_wins() 69scan_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 }