about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rw-r--r--config.h3
-rw-r--r--event.c6
-rw-r--r--gridsel.c47
-rw-r--r--menu.c7
-rw-r--r--util.c38
-rw-r--r--util.h1
7 files changed, 99 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 32c9492..b38889b 100644
--- a/Makefile
+++ b/Makefile
@@ -7,10 +7,12 @@ WMSRC = bar.c client.c cmd.c draw.c event.c key.c util.c wm.c
 WMOBJ = ${WMSRC:.c=.o}
 MENSRC = menu.c draw.c util.c
 MENOBJ = ${MENSRC:.c=.o}
+SELSRC = gridsel.c util.c
+SELOBJ = ${SELSRC:.c=.o}
 MAN1 = gridwm.1 gridmenu.1
-BIN = gridwm gridmenu     
+BIN = gridwm gridmenu gridsel 
 
-all: config gridwm gridmenu
+all: config gridwm gridmenu gridsel
 	@echo finished
 
 config:
@@ -34,6 +36,10 @@ gridwm: ${WMOBJ}
 	@echo LD $@
 	@${CC} -o $@ ${WMOBJ} ${LDFLAGS}
 
+gridsel: ${SELOBJ}
+	@echo LD $@
+	@${CC} -o $@ ${SELOBJ} ${LDFLAGS}
+
 clean:
 	rm -f gridwm gridmenu *.o core
 
diff --git a/config.h b/config.h
index 2f73716..adca4e5 100644
--- a/config.h
+++ b/config.h
@@ -9,7 +9,10 @@
 #define BORDERCOLOR	"#000000"
 #define STATUSCMD	"echo -n `date` `uptime | sed 's/.*://; s/,//g'`" \
 					" `acpi | awk '{print $4}' | sed 's/,//'`"
+#define PLCMD		"`ls -lL /bin /sbin /usr/bin /usr/local/bin 2>/dev/null | awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq | gridmenu`"
+
 #define KEYS		\
 	{ Mod1Mask, XK_Return, run, "xterm -u8 -bg black -fg white -fn '-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*'" }, \
+	{ Mod1Mask, XK_p, run, PLCMD }, \
 	{ Mod1Mask | ShiftMask, XK_q, quit, NULL},
 
diff --git a/event.c b/event.c
index 870ed4a..d168787 100644
--- a/event.c
+++ b/event.c
@@ -81,13 +81,11 @@ configurerequest(XEvent *e)
 static void
 destroynotify(XEvent *e)
 {
-#if 0
 	Client *c;
 	XDestroyWindowEvent *ev = &e->xdestroywindow;
 
-	if((c = client_of_win(ev->window)))
-		destroy_client(c);
-#endif
+	if((c = getclient(ev->window)))
+		unmanage(c);
 }
 
 static void
diff --git a/gridsel.c b/gridsel.c
new file mode 100644
index 0000000..c76105e
--- /dev/null
+++ b/gridsel.c
@@ -0,0 +1,47 @@
+/*
+ * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
+ * See LICENSE file for license details.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <util.h>
+
+static char version[] = "gridsel - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
+
+static void
+usage()
+{
+	fprintf(stderr, "%s\n", "usage: gridsel [-v]\n");
+	exit(1);
+}
+
+int
+main(int argc, char **argv)
+{
+	unsigned char *data;
+	unsigned long i, offset, len, remain;
+
+	/* command line args */
+	if(argc > 1) {
+		if(!strncmp(argv[1], "-v", 3)) {
+			fprintf(stdout, "%s", version);
+			exit(0);
+		} else
+			usage();
+	}
+	len = offset = remain = 0;
+	do {
+		data = getselection(offset, &len, &remain);
+		for(i = 0; i < len; i++)
+			putchar(data[i]);
+		offset += len;
+		free(data);
+	}
+	while(remain);
+	if(offset)
+		putchar('\n');
+	return 0;
+}
diff --git a/menu.c b/menu.c
index ff0ffc1..650fc57 100644
--- a/menu.c
+++ b/menu.c
@@ -356,13 +356,6 @@ main(int argc, char *argv[])
 	char *maxname;
 	XEvent ev;
 
-	char buf[256];
-
-	pipe_spawn(buf, sizeof(buf), NULL, STATUSCMD);
-	fputs(buf, stderr);
-
-	return 0;
-
 	/* command line args */
 	for(i = 1; i < argc; i++) {
 		if (argv[i][0] == '-')
diff --git a/util.c b/util.c
index c0f2489..052d535 100644
--- a/util.c
+++ b/util.c
@@ -10,6 +10,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
+#include <X11/Xatom.h>
 
 #include "util.h"
 
@@ -147,3 +148,40 @@ pipe_spawn(char *buf, unsigned int len, Display *dpy, const char *cmd)
 	}
 	wait(0);
 }
+
+
+unsigned char *
+getselection(unsigned long offset, unsigned long *len, unsigned long *remain)
+{
+	Display *dpy;
+	Atom xa_clip_string;
+	Window w;
+	XEvent ev;
+	Atom typeret;
+	int format;
+	unsigned char *data;
+	unsigned char *result = NULL;
+
+	dpy = XOpenDisplay(0);
+	if(!dpy)
+		return NULL;
+	xa_clip_string = XInternAtom(dpy, "_SEL_STRING", False);
+	w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 200, 200,
+			1, CopyFromParent, CopyFromParent);
+	XConvertSelection(dpy, XA_PRIMARY, XA_STRING, xa_clip_string,
+			w, CurrentTime);
+	XFlush(dpy);
+	XNextEvent(dpy, &ev);
+	if(ev.type == SelectionNotify && ev.xselection.property != None) {
+		XGetWindowProperty(dpy, w, ev.xselection.property, offset, 4096L, False,
+				AnyPropertyType, &typeret, &format, len, remain, &data);
+		if(*len) {
+			result = emalloc(sizeof(unsigned char) * *len);
+			memcpy(result, data, *len);
+		}
+		XDeleteProperty(dpy, w, ev.xselection.property);
+	}
+	XDestroyWindow(dpy, w);
+	XCloseDisplay(dpy);
+	return result;
+}
diff --git a/util.h b/util.h
index 4b82cef..51b0871 100644
--- a/util.h
+++ b/util.h
@@ -17,3 +17,4 @@ extern void failed_assert(char *a, char *file, int line);
 void pipe_spawn(char *buf, unsigned int len, Display *dpy, const char *cmd);
 extern void spawn(Display *dpy, const char *cmd);
 extern void swap(void **p1, void **p2);
+unsigned char *getselection(unsigned long offset, unsigned long *len, unsigned long *remain);
77ec76616fe4165ef92afb14db2bef2488e30'>39677ec ^
8a34fa5 ^
650a1fb ^


8a34fa5 ^
9e8b325 ^
8a34fa5 ^
4d67199 ^
28a5219 ^



4d67199 ^
28a5219 ^
4d67199 ^
650a1fb ^
8a34fa5 ^
b55bd70 ^
9833610 ^
b55bd70 ^
7e597ae ^
9833610 ^
8a34fa5 ^
9833610 ^
b55bd70 ^
7e597ae ^

c73d5cb ^
4881857 ^
7739e6b ^


6458803 ^
8a34fa5 ^
4881857 ^
7739e6b ^

c73d5cb ^








6e72d78 ^

8a34fa5 ^
bf35794 ^
c09bf8d ^

6b25d06 ^
c09bf8d ^

937cabf ^
c09bf8d ^




6b25d06 ^
4688ad1 ^
c09bf8d ^

b355755 ^
c09bf8d ^
b55bd70 ^
78f4b51 ^
c09bf8d ^
78f4b51 ^
e995c1b ^
c09bf8d ^
e995c1b ^
78f4b51 ^
e369292 ^
c09bf8d ^
931e712 ^
7e597ae ^



78f4b51 ^
2dd5212 ^
7e597ae ^
78f4b51 ^
4688ad1 ^
c09bf8d ^
e6cbe9c ^
c09bf8d ^

adaa28a ^
ca65478 ^
fde45eb ^
adaa28a ^
7e597ae ^
b55bd70 ^
adaa28a ^

b55bd70 ^
7e597ae ^


78f4b51 ^
7e597ae ^
e6cbe9c ^
adaa28a ^

9e8b325 ^
ca65478 ^
9e8b325 ^
dc5d967 ^
9e8b325 ^
e81eb46 ^

8a34fa5 ^


8a34fa5 ^
ca65478 ^
d42c3ba ^
d7e1708 ^
8a34fa5 ^
8a8b795 ^
9e8b325 ^


8a34fa5 ^



8a34fa5 ^
9e8b325 ^
8a34fa5 ^


9e8b325 ^







8a34fa5 ^



9e8b325 ^


a308b75 ^
ac6e34e ^
9e8b325 ^

8a34fa5 ^
9e8b325 ^
8a34fa5 ^
adaa28a ^

ca65478 ^
adaa28a ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211