wmii/rc/wmiirc

184 lines
4.0 KiB
Plaintext
Raw Normal View History

#!9PREFIX/bin/rc
# configure wmii
PIDFILE=/tmp/ns.$USER.$DISPLAY/wmiircpid
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
}
WMII_FONT='fixed'
WMII_SELCOLORS='#ffffff #285577 #4c7899'
2006-02-13 11:41:20 +03:00
WMII_NORMCOLORS='#222222 #eeeeee #666666'
2006-02-11 00:33:46 +03:00
CLIENT_BAR=1
2006-02-08 19:34:13 +03:00
CLIENT_BORDER=3
MODKEY=Alt
2006-02-10 19:13:26 +03:00
# WM CONFIGURATION
xwrite /def/bar $CLIENT_BAR
xwrite /def/border $CLIENT_BORDER
xwrite /def/inc 1
2006-02-10 19:13:26 +03:00
xwrite /def/snap 20
xwrite /def/font $WMII_FONT
xwrite /def/selcolors $WMII_SELCOLORS
xwrite /def/normcolors $WMII_NORMCOLORS
2006-02-10 19:11:14 +03:00
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
2006-02-08 19:34:13 +03:00
}
}
}
# KEYS CONFIGURATION
for(i in \
$MODKEY-Control-c \
$MODKEY-Control-w,y \
$MODKEY-Control-q,y \
$MODKEY-Control-p \
$MODKEY-Control-a \
$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)
echo -n | wmiir create /keys/$i
for(i in `{seq 1 9})
echo -n | wmiir create /keys/$MODKEY-$i
2006-02-10 19:13:26 +03:00
# BAR CONFIGURATION
2006-02-10 22:20:29 +03:00
for(i in 1 2 3)
2006-02-10 22:52:32 +03:00
wmiir remove /bar/1 >/dev/null >[2=1]
xwrite /bar/new/colors $WMII_NORMCOLORS
xwrite /bar/new/colors $WMII_SELCOLORS
xwrite /bar/new/colors $WMII_NORMCOLORS
xwrite /bar/1/data 1
xwrite /bar/expand 2
2006-02-10 19:13:26 +03:00
# MENU CONFIGURATION
nl='
'
fn items {
ifs=:$nl { dirs=`{echo $1} }
{
for(dir in $dirs) {
for(file in $dir/*) {
if(! ~ $file $dir^'/*' && ! test -d $file && test -x $file)
echo `{basename $file}
}
}
} | sort | uniq
}
2006-02-11 16:14:12 +03:00
rm -f /tmp/ns.$USER.$DISPLAY/p.menu
2006-02-11 16:32:13 +03:00
@ items $OLD_PATH > /tmp/ns.$USER.$DISPLAY/p.menu &
# MISC
2006-02-13 11:41:20 +03:00
xsetroot -solid '#162028'
status &
2006-02-10 19:13:26 +03:00
# EVENT LOOP
wmiir read /event | \
2006-02-10 18:10:21 +03:00
while(event=`{read}) {
if(~ $event(1) PN)
xwrite /bar/1/data $event(2)
if(~ $event(1) CN) {
text=`{echo $"event | sed 's/^CN //g'}
xwrite /bar/2/data $"text
}
if(~ $event(1) LB) { # label button press
switch($event(3)) { # button
case 1
if(~ $event(2) 1) { # label
xwrite /ctl pager
}
if not {
xwrite /ctl 'select next'
}
case 3
xwrite /ctl 'select prev'
case 4
xwrite /ctl 'select next'
case 5
xwrite /ctl 'select prev'
}
}
2006-02-10 18:10:21 +03:00
if(~ $event(1) K) { # key press
switch($event(2)) {
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-Control-p
extern `{cat /tmp/ns.$USER.$DISPLAY/p.menu | wmiimenu} &
case $MODKEY-Control-a
`{items /usr/local/etc/wmii-3:$HOME/.wmii-3 | wmiimenu} &
case $MODKEY-t
extern xterm -rv &
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 $event(2)|sed 's/.*-//g'}
}
}
}