implemented dwm reading status text from stdin 0e5c8198
Anselm R. Garbe · 2006-07-14 11:57 6 file(s) · +58 −25
config.mk +5 −5
14 14
LIBS = -L${PREFIX}/lib -L/usr/lib -lc -L${X11LIB} -lX11
15 15
16 16
# Linux/BSD
17 -
CFLAGS = -Os -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
18 -
	-DVERSION=\"${VERSION}\"
19 -
LDFLAGS = ${LIBS}
20 -
#CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
17 +
#CFLAGS = -Os -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
21 18
#	-DVERSION=\"${VERSION}\"
22 -
#LDFLAGS = -g ${LIBS}
19 +
#LDFLAGS = ${LIBS}
20 +
CFLAGS = -g -Wall -O2 -I. -I${PREFIX}/include -I/usr/include -I${X11INC} \
21 +
	-DVERSION=\"${VERSION}\"
22 +
LDFLAGS = -g ${LIBS}
23 23
24 24
25 25
# Solaris
dev.c +6 −9
27 27
	{ Mod1Mask,				XK_m,		max,		{ 0 } }, 
28 28
	{ Mod1Mask,				XK_0,		view,		{ .i = Tscratch } }, 
29 29
	{ Mod1Mask,				XK_1,		view,		{ .i = Tdev } }, 
30 -
	{ Mod1Mask,				XK_2,		view,		{ .i = Tirc } }, 
31 -
	{ Mod1Mask,				XK_3,		view,		{ .i = Twww } }, 
32 -
	{ Mod1Mask,				XK_4,		view,		{ .i = Twork } }, 
30 +
	{ Mod1Mask,				XK_2,		view,		{ .i = Twww } }, 
31 +
	{ Mod1Mask,				XK_3,		view,		{ .i = Twork } }, 
33 32
	{ Mod1Mask,				XK_space,	tiling,		{ 0 } }, 
34 33
	{ Mod1Mask|ShiftMask,	XK_space,	floating,	{ 0 } }, 
35 34
	{ Mod1Mask|ShiftMask,	XK_0,		ttrunc,		{ .i = Tscratch } }, 
36 35
	{ Mod1Mask|ShiftMask,	XK_1,		ttrunc,		{ .i = Tdev } }, 
37 -
	{ Mod1Mask|ShiftMask,	XK_2,		ttrunc,		{ .i = Tirc } }, 
38 -
	{ Mod1Mask|ShiftMask,	XK_3,		ttrunc,		{ .i = Twww } }, 
39 -
	{ Mod1Mask|ShiftMask,	XK_4,		ttrunc,		{ .i = Twork } }, 
36 +
	{ Mod1Mask|ShiftMask,	XK_2,		ttrunc,		{ .i = Twww } }, 
37 +
	{ Mod1Mask|ShiftMask,	XK_3,		ttrunc,		{ .i = Twork } }, 
40 38
	{ Mod1Mask|ShiftMask,	XK_c,		ckill,		{ 0 } }, 
41 39
	{ Mod1Mask|ShiftMask,	XK_q,		quit,		{ 0 } },
42 40
	{ Mod1Mask|ShiftMask,	XK_Return,	spawn,		{ .argv = term } },
44 42
	{ Mod1Mask|ShiftMask,	XK_l,		spawn,		{ .argv = xlock } },
45 43
	{ ControlMask,			XK_0,		tappend,	{ .i = Tscratch } }, 
46 44
	{ ControlMask,			XK_1,		tappend,	{ .i = Tdev } }, 
47 -
	{ ControlMask,			XK_2,		tappend,	{ .i = Tirc } }, 
48 -
	{ ControlMask,			XK_3,		tappend,	{ .i = Twww } }, 
49 -
	{ ControlMask,			XK_4,		tappend,	{ .i = Twork } }, 
45 +
	{ ControlMask,			XK_2,		tappend,	{ .i = Twww } }, 
46 +
	{ ControlMask,			XK_3,		tappend,	{ .i = Twork } }, 
50 47
};
51 48
52 49
/********** CUSTOMIZE **********/
dwm.1 +15 −1
81 81
.B nth
82 82
tag to cureent
83 83
.B window
84 -
84 +
.SS Default Mouse Bindings
85 +
.TP
86 +
.B Mod1-Button1
87 +
Moves current
88 +
.B window
89 +
while dragging
90 +
.TP
91 +
.B Mod1-Button2
92 +
Lowers current
93 +
.B window
94 +
.TP
95 +
.B Mod1-Button3
96 +
Resizes current
97 +
.B window
98 +
while dragging
dwm.h +2 −2
9 9
10 10
#define FONT				"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*"
11 11
#define BGCOLOR				"#666699"
12 -
#define FGCOLOR				"#ffffff"
12 +
#define FGCOLOR				"#eeeeee"
13 13
#define BORDERCOLOR			"#9999CC"
14 14
#define MASTERW				52 /* percent */
15 15
#define WM_PROTOCOL_DELWIN	1
16 16
17 17
/* tags */
18 -
enum { Tscratch, Tdev, Tirc, Twww, Twork, TLast };
18 +
enum { Tscratch, Tdev, Twww, Twork, TLast };
19 19
20 20
/********** CUSTOMIZE **********/
21 21
dwm.html +2 −2
69 69
			clients.
70 70
			</li>
71 71
			<li>
72 -
			dwm reads from <b>stdin</b> to print arbirary status text (like the
72 +
			dwm reads from <b>stdin</b> to print arbitrary status text (like the
73 73
			date, load, battery charge). That's much simpler than larsremote,
74 74
			wmiir and what not...
75 75
			</li>
83 83
		</ul>
84 84
		<h3>Screenshot</h3>
85 85
		<p>
86 -
		<a href="http://wmii.de/shots/dwm-20060713.png">Click here for a screenshot</a> (20060713)
86 +
		<a href="http://wmii.de/shots/dwm-20060714.png">Click here for a screenshot</a> (20060714)
87 87
		</p>
88 88
		<h3>Development</h3>
89 89
		<p>
main.c +28 −6
3 3
 * See LICENSE file for license details.
4 4
 */
5 5
6 +
#include <errno.h>
6 7
#include <stdarg.h>
7 8
#include <stdio.h>
8 9
#include <stdlib.h>
9 10
#include <string.h>
11 +
#include <unistd.h>
10 12
11 13
#include <X11/cursorfont.h>
12 14
#include <X11/Xatom.h>
19 21
char *tags[TLast] = {
20 22
	[Tscratch] = "scratch",
21 23
	[Tdev] = "dev",
22 -
	[Tirc] = "irc",
23 24
	[Twww] = "www",
24 25
	[Twork] = "work",
25 26
};
185 186
int
186 187
main(int argc, char *argv[])
187 188
{
188 -
	int i;
189 +
	int i, n;
190 +
	fd_set rd;
189 191
	XSetWindowAttributes wa;
190 192
	unsigned int mask;
191 193
	Window w;
192 194
	XEvent ev;
193 195
194 -
	/* command line args */
195 196
	for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
196 197
		switch (argv[i][1]) {
197 198
		case 'v':
278 279
	scan_wins();
279 280
	draw_bar();
280 281
282 +
	/* main event loop, reads status text from stdin as well */
281 283
	while(running) {
282 -
		XNextEvent(dpy, &ev);
283 -
		if(handler[ev.type])
284 -
			(handler[ev.type])(&ev); /* call handler */
284 +
		FD_ZERO(&rd);
285 +
		FD_SET(0, &rd);
286 +
		FD_SET(ConnectionNumber(dpy), &rd);
287 +
288 +
		i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0);
289 +
		if(i == -1 && errno == EINTR)
290 +
			continue;
291 +
		if(i < 0)
292 +
			error("select failed\n");
293 +
		else if(i > 0) {
294 +
			if(FD_ISSET(ConnectionNumber(dpy), &rd) && XPending(dpy) > 0) {
295 +
				XNextEvent(dpy, &ev);
296 +
				if(handler[ev.type])
297 +
					(handler[ev.type])(&ev); /* call handler */
298 +
			}
299 +
			if(FD_ISSET(0, &rd)) {
300 +
				i = n = 0;
301 +
				while((i = getchar()) != '\n' && n < sizeof(stext) - 1)
302 +
					stext[n++] = i;
303 +
				stext[n] = 0;
304 +
				draw_bar();
305 +
			}
306 +
		}
285 307
	}
286 308
287 309
	cleanup();