wmii/rc/wmiirc

135 lines
2.6 KiB
Bash

#!/bin/sh
# configure wmii
pidfile=/tmp/ns.$USER.$DISPLAY/wmiircpid
xwrite() {
file="$1"; shift
echo -n "$@" | wmiir write "$file"
}
proglist() {
for dir in `echo $@ | sed 's/^:/.:/; s/::/:.:/; s/:$/:./' | tr : ' '`
do
for i in $dir/*
do
test -x "$i" && test ! -d "$i" && echo `basename "$i"`
done
done | sort | uniq
}
test -f $pidfile && kill `cat $pidfile` 2>/dev/null
echo $$ >$pidfile
MODKEY=Alt
WMII_FONT='fixed' export WMII_FONT
WMII_NORMCOLORS='#222222 #eeeeee #666666' export WMII_NORMCOLORS
WMII_SELCOLORS='#ffffff #285577 #4c7899' export WMII_SELCOLORS
# WM CONFIGURATION
xwrite /def/border 3
xwrite /def/snap 20
xwrite /def/font $WMII_FONT
xwrite /def/selcolors $WMII_SELCOLORS
xwrite /def/normcolors $WMII_NORMCOLORS
# BAR CONFIGURATION
while wmiir remove /bar/0 2>/dev/null
do
:
done
xwrite /bar/new/colors $WMII_NORMCOLORS
xwrite /bar/new/colors $WMII_SELCOLORS
xwrite /bar/0/data nil
xwrite /bar/expand 1
# MISC
xsetroot -solid '#0b1014'
status &
proglist $OLD_PATH >/tmp/ns.$USER.$DISPLAY/progs &
# SHORTCUTS
while read key
do
echo -n | wmiir create /keys/$key
done <<EOF
$MODKEY-Control-c
$MODKEY-Control-w,y
$MODKEY-Control-q,y
$MODKEY-Control-p
$MODKEY-Control-a
$MODKEY-t
$MODKEY-Return
$MODKEY-Shift-Return
$MODKEY-h
$MODKEY-l
$MODKEY-j
$MODKEY-k
$MODKEY-Tab
$MODKEY-n
$MODKEY-m
$MODKEY-s
$MODKEY-equal
$MODKEY-Shift-1
$MODKEY-Shift-2
$MODKEY-Shift-3
$MODKEY-Shift-4
$MODKEY-Shift-5
$MODKEY-Shift-6
$MODKEY-Shift-7
$MODKEY-Shift-8
$MODKEY-Shift-9
EOF
# EVENT LOOP
wmiir read /event 2>/dev/null |
while read event
do
set -- $event
type="$1"; shift
case "$type" in
WS)
xwrite /bar/0/data "$@";;
K)
case "$1" in
$MODKEY-Control-c)
xwrite /ws/sel/sel/ctl kill;;
$MODKEY-Control-w,y)
wmiirc &;;
$MODKEY-Control-q,y)
xwrite /ctl quit;;
$MODKEY-Control-p)
extern `wmiimenu </tmp/ns.$USER.$DISPLAY/progs` &;;
$MODKEY-Control-a)
`proglist CONFPREFIX/wmii-3:$HOME/.wmii-3 | wmiimenu` &;;
$MODKEY-t)
extern xterm &;;
$MODKEY-m)
xwrite /ws/sel/mode max;;
$MODKEY-s)
xwrite /ws/sel/mode stack;;
$MODKEY-equal)
xwrite /ws/sel/mode equal;;
$MODKEY-n)
xwrite /ws/sel/sel/ctl sendtoarea new;;
$MODKEY-Return)
xwrite /ws/sel/sel/ctl sendtoarea prev;;
$MODKEY-Shift-Return)
xwrite /ws/sel/sel/ctl sendtoarea next;;
$MODKEY-h)
xwrite /ws/ctl select prev;;
$MODKEY-l)
xwrite /ws/ctl select next;;
$MODKEY-Tab)
xwrite /ws/sel/ctl select next;;
$MODKEY-j)
xwrite /ws/sel/ctl select next;;
$MODKEY-k)
xwrite /ws/sel/ctl select prev;;
$MODKEY-Shift-[0-9])
xwrite /ctl select `echo $1 | sed 's/.*-//'`;;
esac;;
esac
done &
echo $! >$pidfile