summaryrefslogtreecommitdiffstats
path: root/wm.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wm.c60
1 files changed, 6 insertions, 54 deletions
diff --git a/wm.c b/wm.c
index 1c9e1f9..1895015 100644
--- a/wm.c
+++ b/wm.c
@@ -3,15 +3,10 @@
3 * See LICENSE file for license details. 3 * See LICENSE file for license details.
4 */ 4 */
5 5
6#include <errno.h>
7
8#include <stdarg.h> 6#include <stdarg.h>
9#include <stdio.h> 7#include <stdio.h>
10#include <stdlib.h> 8#include <stdlib.h>
11 9
12#include <sys/types.h>
13#include <sys/time.h>
14
15#include <X11/cursorfont.h> 10#include <X11/cursorfont.h>
16#include <X11/Xatom.h> 11#include <X11/Xatom.h>
17#include <X11/Xproto.h> 12#include <X11/Xproto.h>
@@ -28,17 +23,6 @@ char *tags[TLast] = {
28 [Twork] = "work", 23 [Twork] = "work",
29}; 24};
30 25
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 **********/ 26/********** CUSTOMIZE **********/
43 27
44/* X structs */ 28/* X structs */
@@ -51,7 +35,7 @@ Bool issel;
51 35
52char stext[1024]; 36char stext[1024];
53int tsel = Tdev; /* default tag */ 37int tsel = Tdev; /* default tag */
54int screen, sx, sy, sw, sh, bx, by, bw, bh; 38int screen, sx, sy, sw, sh, th;
55 39
56Brush brush = {0}; 40Brush brush = {0};
57Client *clients = NULL; 41Client *clients = NULL;
@@ -209,11 +193,6 @@ main(int argc, char *argv[])
209 unsigned int mask; 193 unsigned int mask;
210 Window w; 194 Window w;
211 XEvent ev; 195 XEvent ev;
212 fd_set fds;
213 struct timeval t, timeout = {
214 .tv_usec = 0,
215 .tv_sec = STATUSDELAY,
216 };
217 196
218 /* command line args */ 197 /* command line args */
219 for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) { 198 for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
@@ -245,7 +224,6 @@ main(int argc, char *argv[])
245 if(other_wm_running) 224 if(other_wm_running)
246 error("gridwm: another window manager is already running\n"); 225 error("gridwm: another window manager is already running\n");
247 226
248 spawn(dpy, cmdwallpaper);
249 sx = sy = 0; 227 sx = sy = 0;
250 sw = DisplayWidth(dpy, screen); 228 sw = DisplayWidth(dpy, screen);
251 sh = DisplayHeight(dpy, screen); 229 sh = DisplayHeight(dpy, screen);
@@ -275,25 +253,11 @@ main(int argc, char *argv[])
275 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR); 253 loadcolors(dpy, screen, &brush, BGCOLOR, FGCOLOR, BORDERCOLOR);
276 loadfont(dpy, &brush.font, FONT); 254 loadfont(dpy, &brush.font, FONT);
277 255
278 wa.override_redirect = 1; 256 th = texth(&brush.font);
279 wa.background_pixmap = ParentRelative;
280 wa.event_mask = ExposureMask;
281
282 bx = by = 0;
283 bw = sw;
284 bh = texth(&brush.font);
285 barwin = XCreateWindow(dpy, root, bx, by, bw, bh, 0, DefaultDepth(dpy, screen),
286 CopyFromParent, DefaultVisual(dpy, screen),
287 CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
288 XDefineCursor(dpy, barwin, cursor[CurNormal]);
289 XMapRaised(dpy, barwin);
290 257
291 brush.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen)); 258 brush.drawable = XCreatePixmap(dpy, root, sw, th, DefaultDepth(dpy, screen));
292 brush.gc = XCreateGC(dpy, root, 0, 0); 259 brush.gc = XCreateGC(dpy, root, 0, 0);
293 260
294 pipe_spawn(stext, sizeof(stext), dpy, cmdstatus);
295 draw_bar();
296
297 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \ 261 wa.event_mask = SubstructureRedirectMask | EnterWindowMask \
298 | LeaveWindowMask; 262 | LeaveWindowMask;
299 wa.cursor = cursor[CurNormal]; 263 wa.cursor = cursor[CurNormal];
@@ -303,21 +267,9 @@ main(int argc, char *argv[])
303 scan_wins(); 267 scan_wins();
304 268
305 while(running) { 269 while(running) {
306 if(XPending(dpy) > 0) { 270 XNextEvent(dpy, &ev);
307 XNextEvent(dpy, &ev); 271 if(handler[ev.type])
308 if(handler[ev.type]) 272 (handler[ev.type])(&ev); /* call handler */
309 (handler[ev.type]) (&ev); /* call handler */
310 continue;
311 }
312 FD_ZERO(&fds);
313 FD_SET(ConnectionNumber(dpy), &fds);
314 t = timeout;
315 if(select(ConnectionNumber(dpy) + 1, &fds, NULL, NULL, &t) > 0)
316 continue;
317 else if(errno != EINTR) {
318 pipe_spawn(stext, sizeof(stext), dpy, cmdstatus);
319 draw_bar();
320 }
321 } 273 }
322 274
323 cleanup(); 275 cleanup();