made things to work again, bar now merged into wm, wmiirc is controller for wmii, changed /tmp/.ixp to /tmp/ns.$USER.$DISPLAY, ixp reuses sockets, so no problem, because wmii checks if a wm is already running, thus socket files cannot be stolen

This commit is contained in:
Anselm R. Garbe 2006-02-10 09:13:35 +01:00
parent 8a663e24d9
commit a38480e40c
7 changed files with 124 additions and 162 deletions

View File

@ -5,11 +5,11 @@ include config.mk
SUBDIRS = libcext liblitz libixp cmd
BIN = cmd/wm/wmii cmd/wm/wmiiwm cmd/wmiibar \
BIN = cmd/wm/wmii cmd/wm/wmiiwm \
cmd/wmiiplumb cmd/wmiir cmd/wmiiwarp
#cmd/wmiimenu cmd/wmiiplumb cmd/wmiir cmd/wmiiwarp
MAN1 = cmd/wm/wmii.1 cmd/wm/wmiiwm.1 cmd/wmiibar.1 \
MAN1 = cmd/wm/wmii.1 cmd/wm/wmiiwm.1 \
cmd/wmiimenu.1 cmd/wmiir.1
all:

View File

@ -27,6 +27,8 @@ static char Enomode[] = "mode not supported";
static char Enofunc[] = "function not supported";
static char Enocommand[] = "command not supported";
#define WMII_IOUNIT 2048
/*
* filesystem specification
* / Droot
@ -36,7 +38,6 @@ static char Enocommand[] = "command not supported";
* /def/snap Fsnap 0..n
* /def/inc Finc 0..n
* /keys/ Dkeys
* /keys/grab Fgrab interface to grab shortcuts
* /keys/foo Fkey
* /bar/ Dbar
* /bar/expand Fexpand id of expandable label
@ -170,7 +171,6 @@ qid_to_name(Qid *qid)
case Fname: return "name"; break;
case Fevent: return "event"; break;
case Fkey: return key[pg]->name; break;
case Fgrab: return "grab"; break;
default: return nil; break;
}
}
@ -189,14 +189,16 @@ name_to_type(char *name, unsigned char dtyp)
if(dtyp == Dpage)
return Darea;
}
if(!strncmp(name, "bar", 4))
return Dbar;
if(!strncmp(name, "bar", 4)) {
if(dtyp == Droot)
return Dbar;
else
return Fbar;
}
if(!strncmp(name, "def", 4))
return Ddef;
if(!strncmp(name, "keys", 5))
return Dkeys;
if(!strncmp(name, "grab", 5))
return Fgrab;
if(!strncmp(name, "ctl", 4))
return Fctl;
if(!strncmp(name, "event", 6))
@ -207,8 +209,6 @@ name_to_type(char *name, unsigned char dtyp)
return Fname;
if(!strncmp(name, "border", 7))
return Fborder;
if(!strncmp(name, "bar", 4))
return Fbar;
if(!strncmp(name, "inc", 4))
return Finc;
if(!strncmp(name, "geometry", 9))
@ -466,7 +466,7 @@ xopen(IXPConn *c, Fcall *fcall)
return Enomode;
fcall->id = ROPEN;
fcall->qid = m->qid;
fcall->iounit = 2048;
fcall->iounit = WMII_IOUNIT;
ixp_server_respond_fcall(c, fcall);
return nil;
}
@ -525,9 +525,6 @@ type_to_stat(Stat *stat, char *name, Qid *dir)
return mkstat(stat, dir, name, 0, DMDIR | DMREAD | DMEXEC);
break;
case Fctl:
case Fgrab:
return mkstat(stat, dir, name, 0, DMWRITE);
break;
case Fevent:
return mkstat(stat, dir, name, 0, DMREAD);
break;
@ -642,7 +639,7 @@ xread(IXPConn *c, Fcall *fcall)
/* jump to offset */
len = type_to_stat(&stat, "ctl", &m->qid);
len += type_to_stat(&stat, "event", &m->qid);
len += type_to_stat(&stat, "default", &m->qid);
len += type_to_stat(&stat, "def", &m->qid);
len += type_to_stat(&stat, "keys", &m->qid);
len += type_to_stat(&stat, "bar", &m->qid);
len += type_to_stat(&stat, "new", &m->qid);
@ -779,7 +776,7 @@ xread(IXPConn *c, Fcall *fcall)
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "event", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "default", &m->qid);
fcall->count += type_to_stat(&stat, "def", &m->qid);
p = ixp_enc_stat(p, &stat);
fcall->count += type_to_stat(&stat, "keys", &m->qid);
p = ixp_enc_stat(p, &stat);
@ -1023,6 +1020,10 @@ xwrite(IXPConn *c, Fcall *fcall)
attach_detached_client();
else if(!strncmp(buf, "select", 6))
select_page(&buf[7]);
else if(!strncmp(buf, "grab ", 5)) {
if(strlen(&buf[5]))
grab_key(create_key(&buf[5]));
}
else
return Enocommand;
break;
@ -1098,52 +1099,6 @@ xwrite(IXPConn *c, Fcall *fcall)
blitz_strtorect(&rect, &page[pg]->area[area]->client[cl]->frame.rect, buf);
/* TODO: resize client */
break;
case Fgrab:
if(fcall->count > 2048)
return Enoperm;
{
static size_t lastcount;
static char last[2048]; /* iounit */
char fcallbuf[2048], tmp[2048]; /* iounit */
char *p1, *p2;
if(!fcall->offset) {
while(nkey) {
Key *k = key[0];
ungrab_key(k);
cext_array_detach((void **)key, k, &keysz);
nkey--;
destroy_key(k);
}
}
if(!fcall->count)
break;
memcpy(fcallbuf, fcall->data, fcall->count);
fcallbuf[fcall->count] = 0;
if(fcall->offset) {
p1 = strrchr(last, '\n');
p2 = strchr(fcallbuf, '\n');
memcpy(tmp, p1, lastcount - (p1 - last));
memcpy(tmp + (lastcount - (p1 - last)), p2, p2 - fcallbuf);
tmp[(lastcount - (p1 - last)) + (p2 - fcallbuf)] = 0;
grab_key(create_key(tmp));
}
else p2 = fcallbuf;
lastcount = fcall->count;
memcpy(last, fcall->data, fcall->count);
while(p2 - fcallbuf < fcall->count) {
p1 = strchr(p2, '\n');
if(!p1)
return "cannot grab, no \n supplied";
*p1 = 0;
grab_key(create_key(p2));
*p1 = '\n';
p2 = ++p1;
}
lastcount = fcall->count;
memcpy(last, fcall->data, fcall->count);
}
break;
case Fexpand:
{
const char *err;

View File

@ -699,6 +699,9 @@ main(int argc, char *argv[])
pmapbar = XCreatePixmap(dpy, winbar, brect.width, brect.height,
DefaultDepth(dpy, screen));
XMapRaised(dpy, winbar);
draw_bar();
/* main event loop */
errstr = ixp_server_loop(&srv);
if(errstr)

View File

@ -32,7 +32,6 @@ enum {
Fdata, /* data to display */
Fcolor,
Fkey,
Fgrab,
Fborder,
Fsnap,
Fbar,

View File

@ -12,21 +12,12 @@ if(! wmiiwm -c) {
WMII_CONFDIR=CONFPREFIX/wmii-3
OLD_PATH=$PATH
PATH=$HOME/.wmii-3:$WMII_CONFDIR:9PREFIX/bin:$PATH
WMII_IDENT=`{date -n}^'-'^$pid
WMII_ADDRESS=unix!/tmp/.ixp-$USER/wmiifs-$WMII_IDENT
WMII_ADDRESS=unix!/tmp/ns.$USER.$DISPLAY/wmii
# start window manager and utilities:
mkdir -p /tmp/.ixp-$USER
wmiifs -a $WMII_ADDRESS &
wmiifspid=$apid
wmiiwm -a unix!/tmp/.ixp-$USER/wmiiwm-$WMII_IDENT &
wmiibar -a unix!/tmp/.ixp-$USER/wmiibar-$WMII_IDENT &
#wmiimenu -a /tmp/.ixp-$USER/wmiimenu-$WMII_IDENT &
sleep 1
# mount ixp file systems:
echo -n mount unix!/tmp/.ixp-$USER/wmiiwm-$WMII_IDENT /wm | wmiir write /ctl
echo -n mount unix!/tmp/.ixp-$USER/wmiibar-$WMII_IDENT /bar | wmiir write /ctl
mkdir -p /tmp/ns.$USER.$DISPLAY
wmiiwm -a $WMII_ADDRESS &
wmiipid=$apid
# display the wmii introduction if necessary:
if(mkdir $HOME/.wmii-3 >[2]/dev/null) {
@ -37,4 +28,4 @@ if(mkdir $HOME/.wmii-3 >[2]/dev/null) {
wmiirc &
# wait for wmiifs's termination:
wait $wmiifspid
wait $wmiipid

View File

@ -1,7 +1,7 @@
#!9PREFIX/bin/rc
# periodically print date and load average to the bar
PIDFILE=/tmp/.ixp-$USER/statuspid-$WMII_IDENT
PIDFILE=/tmp/ns.$USER.$DISPLAY/statuspid-$DISPLAY
fn xwrite { echo -n $2 | wmiir write $1 }
@ -13,7 +13,7 @@ echo $pid >$PIDFILE
# install signal handler for artificial sigexit:
fn sigint {
if(test -f $PIDFILE && ~ `{cat $PIDFILE} $pid)
rm -f $PIDFILE
rm -f $PIDFILE
exit
}

180
rc/wmiirc
View File

@ -1,108 +1,122 @@
#!9PREFIX/bin/rc -x
# configure wmii
PIDFILE=/tmp/ns.$USER.$DISPLAY/wmiircpid-$DISPLAY
fn xwrite { echo -n $2 | wmiir write $1 }
if(test -r $PIDFILE) {
kill -2 `{cat $PIDFILE} >[2]/dev/null
}
echo $pid >$PIDFILE
# install signal handler for artificial sigexit:
fn sigint {
if(test -f $PIDFILE && ~ `{cat $PIDFILE} $pid)
rm -f $PIDFILE
exit
}
CLIENT_BAR=0
CLIENT_BORDER=3
HANDLEINC=1
fn xwrite { echo -n $2 | wmiir write $1 }
MODKEY=Alt
# WMIIWM CONFIGURATION
xwrite /wm/default/bar $CLIENT_BAR
xwrite /wm/default/border $CLIENT_BORDER
xwrite /wm/default/font $FONT
xwrite /wm/default/selcolor $SEL_COLOR
xwrite /wm/default/normcolor $NORM_COLOR
for(page in `{wmiir read /wm | grep '^d' | awk '{print $10}' | grep -v new}) {
for(area in `{wmiir read /wm/$page | grep '^d' | awk '{print $10}' | grep -v new}) {
for(client in `{wmiir read /wm/$page/$area | grep '^d' | awk '{print $10}'}) {
xwrite /wm/$page/$area/$client/bar $CLIENT_BAR
xwrite /wm/$page/$area/$client/border $CLIENT_BORDER
xwrite /def/bar $CLIENT_BAR
xwrite /def/border $CLIENT_BORDER
#xwrite /def/font $FONT
#xwrite /def/selcolor $SEL_COLOR
#xwrite /def/normcolor $NORM_COLOR
for(page in `{wmiir read | grep '^d' | awk '{print $10}' | grep -v new}) {
for(area in `{wmiir read /$page | grep '^d' | awk '{print $10}' | grep -v new}) {
for(client in `{wmiir read /$page/$area | grep '^d' | awk '{print $10}'}) {
xwrite /$page/$area/$client/bar $CLIENT_BAR
xwrite /$page/$area/$client/border $CLIENT_BORDER
}
}
}
for(i in \
$MODKEY-Control-q,y \
$MODKEY-Control-w,y \
$MODKEY-Control-c \
$MODKEY-t \
$MODKEY-d \
$MODKEY-a \
$MODKEY-Shift-a \
$MODKEY-n \
$MODKEY-m \
$MODKEY-Return \
$MODKEY-Shift-Return \
$MODKEY-Control-y \
$MODKEY-h \
$MODKEY-l \
$MODKEY-Tab \
$MODKEY-j \
$MODKEY-k \
$MODKEY-Shift-h \
$MODKEY-Shift-l \
$MODKEY-Shift-p)
xwrite /ctl 'grab '^$i
for(i in 1 2 3 4 5 6 7 8 9)
xwrite /ctl 'grab '^$MODKEY^'-Shift-'^$i
#
# WMIIBAR CONFIGURATION
xwrite /bar/font $FONT
xwrite /bar/defcolor $SEL_COLOR
echo -n fnord | wmiir write /bar/new/data
echo -n key | wmiir write /bar/new/data
# MISC
xsetroot -mod 2 2 -bg '#444466' -fg '#555555'
status&
extern xterm -rv&
status &
wmiir write /wm/keys/grab <<END
Control-Alt-k
Control-Alt-c
Control-Alt-q,y
Control-Alt-w,y
Alt-t
Alt-d
Alt-a
Shift-Alt-a
Alt-n
Alt-m
Alt-Return
Shift-Alt-Return
Control-Alt-y
Alt-h
Alt-l
Alt-Tab
Alt-j
Alt-k
Shift-Alt-h
Shift-Alt-l
Shift-Alt-p
Shift-Alt-1
Shift-Alt-2
Shift-Alt-3
Shift-Alt-4
END
wmiir read /wm/event | \
wmiir read /event | \
while(key=`{read}) {
xwrite /bar/2/data $key
switch($key) {
case Control-Alt-c
xwrite /wm/sel/sel/sel/ctl kill
case Control-Alt-q,y
quit
case Alt-t
case $MODKEY-Control-c
xwrite /sel/sel/sel/ctl kill
case $MODKEY-Control-w,y
wmiirc &
case $MODKEY-Control-q,y
xwrite /ctl quit
case $MODKEY-t
extern xterm -rv &
case Alt-d
xwrite /wm/sel/sel/sel/ctl detach
case Alt-a
xwrite /wm/ctl attach
case Shift-Alt-a
xwrite /wm/ctl detached
case Alt-n
wmiir read /wm/sel/new >/dev/null >[2=1]
case Alt-m
xwrite /wm/sel/sel/sel/ctl max
case Alt-Return
xwrite /wm/sel/sel/ctl 'swap east'
case Shift-Alt-Return
xwrite /wm/sel/sel/ctl 'swap west'
case Control-Alt-y
wmiir read /wm/new >/dev/null >[2=1]
case Alt-h
xwrite /wm/sel/ctl 'select next'
case Alt-l
xwrite /wm/sel/ctl 'select prev'
case Alt-Tab
xwrite /wm/sel/sel/ctl 'select next'
case Alt-j
xwrite /wm/sel/sel/ctl 'select next'
case Alt-k
xwrite /wm/sel/sel/ctl 'select prev'
case Shift-Alt-h
xwrite /wm/ctl 'select prev'
case Shift-Alt-l
xwrite /wm/ctl 'select next'
case Shift-Alt-p
xwrite /wm/ctl pager
case Shift-Alt-[1-9]
xwrite /wm/ctl 'select '^`{echo $k|sed 's/.*-//g'}
case $MODKEY-d
xwrite /sel/sel/sel/ctl detach
case $MODKEY-a
xwrite /ctl attach
case $MODKEY-Shift-a
xwrite /ctl detached
case $MODKEY-n
wmiir read /sel/new >/dev/null >[2=1]
case $MODKEY-m
xwrite /sel/sel/sel/ctl max
case $MODKEY-Return
xwrite /sel/sel/ctl 'swap east'
case $MODKEY-Shift-Return
xwrite /sel/sel/ctl 'swap west'
case $MODKEY-Control-y
wmiir read /new >/dev/null >[2=1]
case $MODKEY-h
xwrite /sel/ctl 'select next'
case $MODKEY-l
xwrite /sel/ctl 'select prev'
case $MODKEY-Tab
xwrite /sel/sel/ctl 'select next'
case $MODKEY-j
xwrite /sel/sel/ctl 'select next'
case $MODKEY-k
xwrite /sel/sel/ctl 'select prev'
case $MODKEY-Shift-h
xwrite /ctl 'select prev'
case $MODKEY-Shift-l
xwrite /ctl 'select next'
case $MODKEY-Shift-p
xwrite /ctl pager
case $MODKEY-Shift-[1-9]
xwrite /ctl 'select '^`{echo $k|sed 's/.*-//g'}
}
}