aewl
changeset 11:ea9c08ec4b48
added gridsel to gridwm
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Tue, 11 Jul 2006 13:21:57 +0200 |
parents | 703255003abb |
children | a2b399582afe |
files | Makefile config.h event.c gridsel.c menu.c util.c util.h |
diffstat | 7 files changed, 99 insertions(+), 13 deletions(-) [+] |
line diff
1.1 --- a/Makefile Tue Jul 11 13:02:22 2006 +0200 1.2 +++ b/Makefile Tue Jul 11 13:21:57 2006 +0200 1.3 @@ -7,10 +7,12 @@ 1.4 WMOBJ = ${WMSRC:.c=.o} 1.5 MENSRC = menu.c draw.c util.c 1.6 MENOBJ = ${MENSRC:.c=.o} 1.7 +SELSRC = gridsel.c util.c 1.8 +SELOBJ = ${SELSRC:.c=.o} 1.9 MAN1 = gridwm.1 gridmenu.1 1.10 -BIN = gridwm gridmenu 1.11 +BIN = gridwm gridmenu gridsel 1.12 1.13 -all: config gridwm gridmenu 1.14 +all: config gridwm gridmenu gridsel 1.15 @echo finished 1.16 1.17 config: 1.18 @@ -34,6 +36,10 @@ 1.19 @echo LD $@ 1.20 @${CC} -o $@ ${WMOBJ} ${LDFLAGS} 1.21 1.22 +gridsel: ${SELOBJ} 1.23 + @echo LD $@ 1.24 + @${CC} -o $@ ${SELOBJ} ${LDFLAGS} 1.25 + 1.26 clean: 1.27 rm -f gridwm gridmenu *.o core 1.28
2.1 --- a/config.h Tue Jul 11 13:02:22 2006 +0200 2.2 +++ b/config.h Tue Jul 11 13:21:57 2006 +0200 2.3 @@ -9,7 +9,10 @@ 2.4 #define BORDERCOLOR "#000000" 2.5 #define STATUSCMD "echo -n `date` `uptime | sed 's/.*://; s/,//g'`" \ 2.6 " `acpi | awk '{print $4}' | sed 's/,//'`" 2.7 +#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`" 2.8 + 2.9 #define KEYS \ 2.10 { Mod1Mask, XK_Return, run, "xterm -u8 -bg black -fg white -fn '-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*'" }, \ 2.11 + { Mod1Mask, XK_p, run, PLCMD }, \ 2.12 { Mod1Mask | ShiftMask, XK_q, quit, NULL}, 2.13
3.1 --- a/event.c Tue Jul 11 13:02:22 2006 +0200 3.2 +++ b/event.c Tue Jul 11 13:21:57 2006 +0200 3.3 @@ -81,13 +81,11 @@ 3.4 static void 3.5 destroynotify(XEvent *e) 3.6 { 3.7 -#if 0 3.8 Client *c; 3.9 XDestroyWindowEvent *ev = &e->xdestroywindow; 3.10 3.11 - if((c = client_of_win(ev->window))) 3.12 - destroy_client(c); 3.13 -#endif 3.14 + if((c = getclient(ev->window))) 3.15 + unmanage(c); 3.16 } 3.17 3.18 static void
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/gridsel.c Tue Jul 11 13:21:57 2006 +0200 4.3 @@ -0,0 +1,47 @@ 4.4 +/* 4.5 + * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 4.6 + * See LICENSE file for license details. 4.7 + */ 4.8 + 4.9 +#include <stdlib.h> 4.10 +#include <stdio.h> 4.11 +#include <string.h> 4.12 + 4.13 +#include <util.h> 4.14 + 4.15 +static char version[] = "gridsel - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; 4.16 + 4.17 +static void 4.18 +usage() 4.19 +{ 4.20 + fprintf(stderr, "%s\n", "usage: gridsel [-v]\n"); 4.21 + exit(1); 4.22 +} 4.23 + 4.24 +int 4.25 +main(int argc, char **argv) 4.26 +{ 4.27 + unsigned char *data; 4.28 + unsigned long i, offset, len, remain; 4.29 + 4.30 + /* command line args */ 4.31 + if(argc > 1) { 4.32 + if(!strncmp(argv[1], "-v", 3)) { 4.33 + fprintf(stdout, "%s", version); 4.34 + exit(0); 4.35 + } else 4.36 + usage(); 4.37 + } 4.38 + len = offset = remain = 0; 4.39 + do { 4.40 + data = getselection(offset, &len, &remain); 4.41 + for(i = 0; i < len; i++) 4.42 + putchar(data[i]); 4.43 + offset += len; 4.44 + free(data); 4.45 + } 4.46 + while(remain); 4.47 + if(offset) 4.48 + putchar('\n'); 4.49 + return 0; 4.50 +}
5.1 --- a/menu.c Tue Jul 11 13:02:22 2006 +0200 5.2 +++ b/menu.c Tue Jul 11 13:21:57 2006 +0200 5.3 @@ -356,13 +356,6 @@ 5.4 char *maxname; 5.5 XEvent ev; 5.6 5.7 - char buf[256]; 5.8 - 5.9 - pipe_spawn(buf, sizeof(buf), NULL, STATUSCMD); 5.10 - fputs(buf, stderr); 5.11 - 5.12 - return 0; 5.13 - 5.14 /* command line args */ 5.15 for(i = 1; i < argc; i++) { 5.16 if (argv[i][0] == '-')
6.1 --- a/util.c Tue Jul 11 13:02:22 2006 +0200 6.2 +++ b/util.c Tue Jul 11 13:21:57 2006 +0200 6.3 @@ -10,6 +10,7 @@ 6.4 #include <sys/types.h> 6.5 #include <sys/wait.h> 6.6 #include <unistd.h> 6.7 +#include <X11/Xatom.h> 6.8 6.9 #include "util.h" 6.10 6.11 @@ -147,3 +148,40 @@ 6.12 } 6.13 wait(0); 6.14 } 6.15 + 6.16 + 6.17 +unsigned char * 6.18 +getselection(unsigned long offset, unsigned long *len, unsigned long *remain) 6.19 +{ 6.20 + Display *dpy; 6.21 + Atom xa_clip_string; 6.22 + Window w; 6.23 + XEvent ev; 6.24 + Atom typeret; 6.25 + int format; 6.26 + unsigned char *data; 6.27 + unsigned char *result = NULL; 6.28 + 6.29 + dpy = XOpenDisplay(0); 6.30 + if(!dpy) 6.31 + return NULL; 6.32 + xa_clip_string = XInternAtom(dpy, "_SEL_STRING", False); 6.33 + w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 200, 200, 6.34 + 1, CopyFromParent, CopyFromParent); 6.35 + XConvertSelection(dpy, XA_PRIMARY, XA_STRING, xa_clip_string, 6.36 + w, CurrentTime); 6.37 + XFlush(dpy); 6.38 + XNextEvent(dpy, &ev); 6.39 + if(ev.type == SelectionNotify && ev.xselection.property != None) { 6.40 + XGetWindowProperty(dpy, w, ev.xselection.property, offset, 4096L, False, 6.41 + AnyPropertyType, &typeret, &format, len, remain, &data); 6.42 + if(*len) { 6.43 + result = emalloc(sizeof(unsigned char) * *len); 6.44 + memcpy(result, data, *len); 6.45 + } 6.46 + XDeleteProperty(dpy, w, ev.xselection.property); 6.47 + } 6.48 + XDestroyWindow(dpy, w); 6.49 + XCloseDisplay(dpy); 6.50 + return result; 6.51 +}
7.1 --- a/util.h Tue Jul 11 13:02:22 2006 +0200 7.2 +++ b/util.h Tue Jul 11 13:21:57 2006 +0200 7.3 @@ -17,3 +17,4 @@ 7.4 void pipe_spawn(char *buf, unsigned int len, Display *dpy, const char *cmd); 7.5 extern void spawn(Display *dpy, const char *cmd); 7.6 extern void swap(void **p1, void **p2); 7.7 +unsigned char *getselection(unsigned long offset, unsigned long *len, unsigned long *remain);