wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 3b03fb1c94a2840b4fd57a3d0ca0cf8bf6e7f1b3
parent 94d277aad921240a9dd4ff3c291d98087bbc7159
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Wed,  8 Feb 2006 18:33:01 +0100

simplified  internal action access


Diffstat:
cmd/wm/page.c | 4+++-
libwmii/spawn.c | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
rc/wmiirc | 43+++++++++++++++++++------------------------
3 files changed, 87 insertions(+), 33 deletions(-)

diff --git a/cmd/wm/page.c b/cmd/wm/page.c @@ -100,8 +100,10 @@ focus_page(Page *p) Client *c = client[i]; if(old && (c->page == old)) XMoveWindow(dpy, c->frame.win, 2 * rect.width, 2 * rect.height); - else if(c->page == p) + else if(c->page == p) { XMoveWindow(dpy, c->frame.win, c->frame.rect.x, c->frame.rect.y); + draw_client(c); + } } do_pend_fcall("SelPage\n"); XChangeProperty(dpy, root, net_atoms[NET_CURRENT_DESKTOP], XA_CARDINAL, diff --git a/libwmii/spawn.c b/libwmii/spawn.c @@ -5,25 +5,82 @@ #include <stdlib.h> #include <stdio.h> +#include <string.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include "wmii.h" -void +static void +spawn_ixp_write(char *cmd) +{ + IXPClient c; + char *file = cmd; + char *data = strchr(cmd, ' '); + char *address = strdup(getenv("WMII_ADDRESS")); + unsigned int fid = c.root_fid << 2; + size_t len; + + if(!data || !cmd || !address) + return; + *data = 0; + data++; + len = strlen(data); + fprintf(stderr, "spawn_ixp_write write file=%s data=%s address=%s\n", file, data, address); + + if(ixp_client_init(&c, address, getpid()) == -1) { + free(address); + fprintf(stderr, "libwmii: %s\n", c.errstr); + return; + } + free(address); + /* open */ + if(ixp_client_open(&c, fid, file, IXP_OWRITE) == -1) { + fprintf(stderr, "libwmii: cannot open file '%s': %s\n", file, c.errstr); + return; + } + if(ixp_client_write(&c, fid, 0, len, (void *)data) != len) { + fprintf(stderr, "libwmii: cannot write file: %s\n", c.errstr); + return; + } + ixp_client_close(&c, fid); + ixp_client_deinit(&c); +} + +void wmii_spawn(void *dpy, char *cmd) { - /* double-fork catches all zombies */ - if (fork() == 0) { - if (fork() == 0) { + static char *ixpcmd = nil; + static size_t ixpcmdsz = 0; + size_t len; + + if(!cmd) + return; + if(!strncmp(cmd, "#write ", 7)) { + if(!(len = strlen(&cmd[7]) + 1)) + return; + if(len > ixpcmdsz) { + ixpcmdsz = len + 1; + if(ixpcmd) + free(ixpcmd); + ixpcmd = cext_emallocz(ixpcmdsz); + } + cext_strlcpy(ixpcmd, &cmd[7], len); + spawn_ixp_write(ixpcmd); + return; + } + + /* the questionable double-fork is done to catch all zombies */ + if(fork() == 0) { + if(fork() == 0) { setsid(); close(ConnectionNumber(dpy)); execlp("rc", "rc", "-c", cmd, (char *) 0); perror("failed"); exit(1); - } - exit(0); - } - wait(0); + } + exit(0); + } + wait(0); } diff --git a/rc/wmiirc b/rc/wmiirc @@ -28,35 +28,30 @@ for(page in `{wmiir read /wm | grep '^d' | awk '{print $10}' | grep -v new}) { # WMIIKEYS CONFIGURATION cat | wmiir write /keys/reset <<END -Control-Alt-c echo -n kill | wmiir write /wm/sel/sel/sel/ctl +Control-Alt-c #write /wm/sel/sel/sel/ctl kill Control-Alt-q,y quit Control-Alt-w,y wmiirc Alt-t extern xterm -rv -Alt-d echo -n detach | wmiir write /wm/sel/sel/sel/ctl -Alt-a echo -n attach | wmiir write /wm/ctl -Shift-Alt-a echo -n detached | wmiir write /wm/ctl +Alt-d #write /wm/sel/sel/sel/ctl detach +Alt-a #write /wm/ctl attach +Shift-Alt-a #write /wm/ctl detached Alt-n wmiir read /wm/sel/new >/dev/null >[2=1] -Alt-m echo -n max | wmiir write /wm/sel/sel/sel/ctl -Alt-Return echo -n swap west | wmiir write /wm/sel/sel/ctl -Shift-Alt-Return echo -n swap east | wmiir write /wm/sel/sel/ctl +Alt-m #write /wm/sel/sel/sel/ctl max +Alt-Return #write /wm/sel/sel/ctl swap east +Shift-Alt-Return #write /wm/sel/sel/ctl swap west Control-Alt-y wmiir read /wm/new >/dev/null >[2=1] -Alt-h echo -n select next | wmiir write /wm/sel/ctl -Alt-l echo -n select prev | wmiir write /wm/sel/ctl -Alt-Tab echo -n select next | wmiir write /wm/sel/sel/ctl -Alt-j echo -n select next | wmiir write /wm/sel/sel/ctl -Alt-k echo -n select prev | wmiir write /wm/sel/sel/ctl -Shift-Alt-h echo -n select prev | wmiir write /wm/ctl -Shift-Alt-l echo -n select next | wmiir write /wm/ctl -Shift-Alt-p echo -n pager | wmiir write /wm/ctl -Shift-Alt-1 echo -n select 1 | wmiir write /wm/ctl -Shift-Alt-2 echo -n select 2 | wmiir write /wm/ctl -Shift-Alt-3 echo -n select 3 | wmiir write /wm/ctl -Shift-Alt-4 echo -n select 4 | wmiir write /wm/ctl -Shift-Alt-5 echo -n select 5 | wmiir write /wm/ctl -Shift-Alt-6 echo -n select 6 | wmiir write /wm/ctl -Shift-Alt-7 echo -n select 7 | wmiir write /wm/ctl -Shift-Alt-8 echo -n select 8 | wmiir write /wm/ctl -Shift-Alt-9 echo -n select 9 | wmiir write /wm/ctl +Alt-h #write /wm/sel/ctl select next +Alt-l #write /wm/sel/ctl select prev +Alt-Tab #write /wm/sel/sel/ctl select next +Alt-j #write /wm/sel/sel/ctl select next +Alt-k #write /wm/sel/sel/ctl select prev +Shift-Alt-h #write /wm/ctl select prev +Shift-Alt-l #write /wm/ctl select next +Shift-Alt-p #write /wm/ctl pager +Shift-Alt-1 #write /wm/ctl select 1 +Shift-Alt-2 #write /wm/ctl select 2 +Shift-Alt-3 #write /wm/ctl select 3 +Shift-Alt-4 #write /wm/ctl select 4 END xwrite /keys/font $FONT