added gridsel to gridwm
This commit is contained in:
parent
005362043d
commit
26e134b8a7
10
Makefile
10
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}
|
WMOBJ = ${WMSRC:.c=.o}
|
||||||
MENSRC = menu.c draw.c util.c
|
MENSRC = menu.c draw.c util.c
|
||||||
MENOBJ = ${MENSRC:.c=.o}
|
MENOBJ = ${MENSRC:.c=.o}
|
||||||
|
SELSRC = gridsel.c util.c
|
||||||
|
SELOBJ = ${SELSRC:.c=.o}
|
||||||
MAN1 = gridwm.1 gridmenu.1
|
MAN1 = gridwm.1 gridmenu.1
|
||||||
BIN = gridwm gridmenu
|
BIN = gridwm gridmenu gridsel
|
||||||
|
|
||||||
all: config gridwm gridmenu
|
all: config gridwm gridmenu gridsel
|
||||||
@echo finished
|
@echo finished
|
||||||
|
|
||||||
config:
|
config:
|
||||||
@ -34,6 +36,10 @@ gridwm: ${WMOBJ}
|
|||||||
@echo LD $@
|
@echo LD $@
|
||||||
@${CC} -o $@ ${WMOBJ} ${LDFLAGS}
|
@${CC} -o $@ ${WMOBJ} ${LDFLAGS}
|
||||||
|
|
||||||
|
gridsel: ${SELOBJ}
|
||||||
|
@echo LD $@
|
||||||
|
@${CC} -o $@ ${SELOBJ} ${LDFLAGS}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f gridwm gridmenu *.o core
|
rm -f gridwm gridmenu *.o core
|
||||||
|
|
||||||
|
3
config.h
3
config.h
@ -9,7 +9,10 @@
|
|||||||
#define BORDERCOLOR "#000000"
|
#define BORDERCOLOR "#000000"
|
||||||
#define STATUSCMD "echo -n `date` `uptime | sed 's/.*://; s/,//g'`" \
|
#define STATUSCMD "echo -n `date` `uptime | sed 's/.*://; s/,//g'`" \
|
||||||
" `acpi | awk '{print $4}' | sed 's/,//'`"
|
" `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 \
|
#define KEYS \
|
||||||
{ Mod1Mask, XK_Return, run, "xterm -u8 -bg black -fg white -fn '-*-terminus-medium-*-*-*-14-*-*-*-*-*-iso10646-*'" }, \
|
{ 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},
|
{ Mod1Mask | ShiftMask, XK_q, quit, NULL},
|
||||||
|
|
||||||
|
6
event.c
6
event.c
@ -81,13 +81,11 @@ configurerequest(XEvent *e)
|
|||||||
static void
|
static void
|
||||||
destroynotify(XEvent *e)
|
destroynotify(XEvent *e)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
Client *c;
|
Client *c;
|
||||||
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
||||||
|
|
||||||
if((c = client_of_win(ev->window)))
|
if((c = getclient(ev->window)))
|
||||||
destroy_client(c);
|
unmanage(c);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
47
gridsel.c
Normal file
47
gridsel.c
Normal file
@ -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;
|
||||||
|
}
|
7
menu.c
7
menu.c
@ -356,13 +356,6 @@ main(int argc, char *argv[])
|
|||||||
char *maxname;
|
char *maxname;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
char buf[256];
|
|
||||||
|
|
||||||
pipe_spawn(buf, sizeof(buf), NULL, STATUSCMD);
|
|
||||||
fputs(buf, stderr);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* command line args */
|
/* command line args */
|
||||||
for(i = 1; i < argc; i++) {
|
for(i = 1; i < argc; i++) {
|
||||||
if (argv[i][0] == '-')
|
if (argv[i][0] == '-')
|
||||||
|
38
util.c
38
util.c
@ -10,6 +10,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
@ -147,3 +148,40 @@ pipe_spawn(char *buf, unsigned int len, Display *dpy, const char *cmd)
|
|||||||
}
|
}
|
||||||
wait(0);
|
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;
|
||||||
|
}
|
||||||
|
1
util.h
1
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);
|
void pipe_spawn(char *buf, unsigned int len, Display *dpy, const char *cmd);
|
||||||
extern void spawn(Display *dpy, const char *cmd);
|
extern void spawn(Display *dpy, const char *cmd);
|
||||||
extern void swap(void **p1, void **p2);
|
extern void swap(void **p1, void **p2);
|
||||||
|
unsigned char *getselection(unsigned long offset, unsigned long *len, unsigned long *remain);
|
||||||
|
Loading…
Reference in New Issue
Block a user