wmii/rc/wmiirc

171 lines
3.2 KiB
Bash

#!/bin/sh
# configure wmii
xwrite() {
file="$1"; shift
echo -n "$@" | wmiir write "$file"
}
proglist() {
ls -lL `echo "$@" | tr : ' '` 2>/dev/null |
awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort -u
}
MODKEY=Alt
WMII_FONT='fixed' export WMII_FONT
WMII_NORMCOLORS='#222222 #eeeeee #666666' export WMII_NORMCOLORS
WMII_SELCOLORS='#ffffff #285577 #4c7899' export WMII_SELCOLORS
# give wmiiwm a chance to start
while :
do
echo Start wmiirc | wmiir write /event >/dev/null 2>&1 && break
sleep 1
done
# WM CONFIGURATION
xwrite /def/border 2
xwrite /def/font $WMII_FONT
xwrite /def/selcolors $WMII_SELCOLORS
xwrite /def/normcolors $WMII_NORMCOLORS
# TAGGING RULES
wmiir write /def/rules <<EOF
/XMMS:.*/ -> ~
/Gimp.*:.*/ -> ~
EOF
# BAR CONFIGURATION
wmiir create /bar/spare
xwrite /bar/spare/colors $WMII_SELCOLORS
xwrite /bar/expand spare
# MISC
xsetroot -solid '#0b1014'
status &
proglist $OLD_PATH >/tmp/ns.$USER.$DISPLAY/progs &
# SHORTCUTS
wmiir write /def/keys <<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-space
$MODKEY-Shift-space
$MODKEY-h
$MODKEY-l
$MODKEY-j
$MODKEY-k
$MODKEY-Tab
$MODKEY-n
$MODKEY-m
$MODKEY-s
$MODKEY-e
$MODKEY-0
$MODKEY-1
$MODKEY-2
$MODKEY-3
$MODKEY-4
$MODKEY-5
$MODKEY-6
$MODKEY-7
$MODKEY-8
$MODKEY-9
$MODKEY-Shift-0
$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
Start)
if test wmiirc = "$1"
then
exit
fi;;
NewTag)
wmiir create /bar/$1
if test "X$1" = "X$oldtag"
then
xwrite /bar/$1/colors $WMII_NORMCOLORS
else
xwrite /bar/$1/colors $WMII_SELCOLORS
fi
xwrite /bar/$1/data $1;;
RemoveTag)
wmiir remove /bar/$1;;
FocusTag)
if test -n "$oldtag"
then
xwrite /bar/$oldtag/colors $WMII_SELCOLORS
fi
xwrite /bar/$1/data $1
xwrite /bar/$1/colors $WMII_NORMCOLORS
oldtag=$1;;
LabelClick)
xwrite /ctl view $1;;
Key)
case "$1" in
$MODKEY-Control-c)
xwrite /view/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 /view/sel/mode max;;
$MODKEY-s)
xwrite /view/sel/mode stack;;
$MODKEY-e)
xwrite /view/sel/mode equal;;
$MODKEY-n)
xwrite /view/sel/sel/ctl sendto new;;
$MODKEY-Return)
xwrite /view/sel/sel/ctl sendto prev;;
$MODKEY-Shift-Return)
xwrite /view/sel/sel/ctl sendto next;;
$MODKEY-space)
xwrite /view/ctl select toggle;;
$MODKEY-Shift-space)
xwrite /view/sel/sel/ctl sendto toggle;;
$MODKEY-h)
xwrite /view/ctl select prev;;
$MODKEY-l)
xwrite /view/ctl select next;;
$MODKEY-Tab)
xwrite /view/sel/ctl select next;;
$MODKEY-j)
xwrite /view/sel/ctl select next;;
$MODKEY-k)
xwrite /view/sel/ctl select prev;;
$MODKEY-[0-9])
xwrite /ctl view `echo $1 | sed 's/.*-//'`;;
$MODKEY-Shift-[0-9])
xwrite /view/sel/sel/tags `echo $1 | sed 's/.*-//'`;;
esac;;
esac
done