summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-11 13:21:57 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-11 13:21:57 +0200
commit26e134b8a7dae21a699822009674b3131de6e250 (patch)
treece783ecc7317440d3947eff29c42075620e98858
parentchanged how manage client works (diff)
downloaddwm-26e134b8a7dae21a699822009674b3131de6e250.tar.gz
dwm-26e134b8a7dae21a699822009674b3131de6e250.zip
added gridsel to gridwm
-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
7WMOBJ = ${WMSRC:.c=.o} 7WMOBJ = ${WMSRC:.c=.o}
8MENSRC = menu.c draw.c util.c 8MENSRC = menu.c draw.c util.c
9MENOBJ = ${MENSRC:.c=.o} 9MENOBJ = ${MENSRC:.c=.o}
10SELSRC = gridsel.c util.c
11SELOBJ = ${SELSRC:.c=.o}
10MAN1 = gridwm.1 gridmenu.1 12MAN1 = gridwm.1 gridmenu.1
11BIN = gridwm gridmenu 13BIN = gridwm gridmenu gridsel
12 14
13all: config gridwm gridmenu 15all: config gridwm gridmenu gridsel
14 @echo finished 16 @echo finished
15 17
16config: 18config:
@@ -34,6 +36,10 @@ gridwm: ${WMOBJ}
34 @echo LD $@ 36 @echo LD $@
35 @${CC} -o $@ ${WMOBJ} ${LDFLAGS} 37 @${CC} -o $@ ${WMOBJ} ${LDFLAGS}
36 38
39gridsel: ${SELOBJ}
40 @echo LD $@
41 @${CC} -o $@ ${SELOBJ} ${LDFLAGS}
42
37clean: 43clean:
38 rm -f gridwm gridmenu *.o core 44 rm -f gridwm gridmenu *.o core
39 45
diff --git a/config.h b/config.h
index 2f73716..adca4e5 100644
--- a/config.h
+++ b/config.h
@@ -9,7 +9,10 @@
9#define BORDERCOLOR "#000000" 9#define BORDERCOLOR "#000000"
10#define STATUSCMD "echo -n `date` `uptime | sed 's/.*://; s/,//g'`" \ 10#define STATUSCMD "echo -n `date` `uptime | sed 's/.*://; s/,//g'`" \
11 " `acpi | awk '{print $4}' | sed 's/,//'`" 11 " `acpi | awk '{print $4}' | sed 's/,//'`"
12#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`"
13
12#define KEYS \ 14#define KEYS \
13 { Mod1Mask, XK_Return, run, "xterm -u8 -bg black -fg white -fn '-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*'" }, \ 15 { Mod1Mask, XK_Return, run, "xterm -u8 -bg black -fg white -fn '-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*'" }, \
16 { Mod1Mask, XK_p, run, PLCMD }, \
14 { Mod1Mask | ShiftMask, XK_q, quit, NULL}, 17 { Mod1Mask | ShiftMask, XK_q, quit, NULL},
15 18
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)
81static void 81static void
82destroynotify(XEvent *e) 82destroynotify(XEvent *e)
83{ 83{
84#if 0
85 Client *c; 84 Client *c;
86 XDestroyWindowEvent *ev = &e->xdestroywindow; 85 XDestroyWindowEvent *ev = &e->xdestroywindow;
87 86
88 if((c = client_of_win(ev->window))) 87 if((c = getclient(ev->window)))
89 destroy_client(c); 88 unmanage(c);
90#endif
91} 89}
92 90
93static void 91static 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 @@
1/*
2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
3 * See LICENSE file for license details.
4 */
5
6#include <stdlib.h>
7#include <stdio.h>
8#include <string.h>
9
10#include <util.h>
11
12static char version[] = "gridsel - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n";
13
14static void
15usage()
16{
17 fprintf(stderr, "%s\n", "usage: gridsel [-v]\n");
18 exit(1);
19}
20
21int
22main(int argc, char **argv)
23{
24 unsigned char *data;
25 unsigned long i, offset, len, remain;
26
27 /* command line args */
28 if(argc > 1) {
29 if(!strncmp(argv[1], "-v", 3)) {
30 fprintf(stdout, "%s", version);
31 exit(0);
32 } else
33 usage();
34 }
35 len = offset = remain = 0;
36 do {
37 data = getselection(offset, &len, &remain);
38 for(i = 0; i < len; i++)
39 putchar(data[i]);
40 offset += len;
41 free(data);
42 }
43 while(remain);
44 if(offset)
45 putchar('\n');
46 return 0;
47}
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[])
356 char *maxname; 356 char *maxname;
357 XEvent ev; 357 XEvent ev;
358 358
359 char buf[256];
360
361 pipe_spawn(buf, sizeof(buf), NULL, STATUSCMD);
362 fputs(buf, stderr);
363
364 return 0;
365
366 /* command line args */ 359 /* command line args */
367 for(i = 1; i < argc; i++) { 360 for(i = 1; i < argc; i++) {
368 if (argv[i][0] == '-') 361 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 @@
10#include <sys/types.h> 10#include <sys/types.h>
11#include <sys/wait.h> 11#include <sys/wait.h>
12#include <unistd.h> 12#include <unistd.h>
13#include <X11/Xatom.h>
13 14
14#include "util.h" 15#include "util.h"
15 16
@@ -147,3 +148,40 @@ pipe_spawn(char *buf, unsigned int len, Display *dpy, const char *cmd)
147 } 148 }
148 wait(0); 149 wait(0);
149} 150}
151
152
153unsigned char *
154getselection(unsigned long offset, unsigned long *len, unsigned long *remain)
155{
156 Display *dpy;
157 Atom xa_clip_string;
158 Window w;
159 XEvent ev;
160 Atom typeret;
161 int format;
162 unsigned char *data;
163 unsigned char *result = NULL;
164
165 dpy = XOpenDisplay(0);
166 if(!dpy)
167 return NULL;
168 xa_clip_string = XInternAtom(dpy, "_SEL_STRING", False);
169 w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 200, 200,
170 1, CopyFromParent, CopyFromParent);
171 XConvertSelection(dpy, XA_PRIMARY, XA_STRING, xa_clip_string,
172 w, CurrentTime);
173 XFlush(dpy);
174 XNextEvent(dpy, &ev);
175 if(ev.type == SelectionNotify && ev.xselection.property != None) {
176 XGetWindowProperty(dpy, w, ev.xselection.property, offset, 4096L, False,
177 AnyPropertyType, &typeret, &format, len, remain, &data);
178 if(*len) {
179 result = emalloc(sizeof(unsigned char) * *len);
180 memcpy(result, data, *len);
181 }
182 XDeleteProperty(dpy, w, ev.xselection.property);
183 }
184 XDestroyWindow(dpy, w);
185 XCloseDisplay(dpy);
186 return result;
187}
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);
17void pipe_spawn(char *buf, unsigned int len, Display *dpy, const char *cmd); 17void pipe_spawn(char *buf, unsigned int len, Display *dpy, const char *cmd);
18extern void spawn(Display *dpy, const char *cmd); 18extern void spawn(Display *dpy, const char *cmd);
19extern void swap(void **p1, void **p2); 19extern void swap(void **p1, void **p2);
20unsigned char *getselection(unsigned long offset, unsigned long *len, unsigned long *remain);