wmii/rc/wmiirc

220 lines
4.3 KiB
Plaintext
Raw Normal View History

#!/bin/sh
2006-02-25 19:36:53 +01:00
# configure wmii
xwrite() {
file="$1"; shift
echo -n "$@" | wmiir write "$file"
2006-02-25 19:36:53 +01:00
}
proglist() {
ls -lL "$@" 2>/dev/null | awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq
}
conf_which () {
if [ -n "$1" ]
then
prog=$1; shift
echo `PATH="$WMII_CONFPATH:$PATH" which $prog` "$@"
fi
2006-02-25 19:36:53 +01:00
}
tagsmenu() {
tag=`wmiir read /tag/sel/ctl`
tags=`wmiir ls /tag | sed 's|/||; /^sel$/d' | awk "BEGIN{print \"$tag\"} !/^$tag\$/" | $DMENU`
test -n "$tags" && xwrite $@ "$tags"
}
MODKEY=Mod1
UP=k
DOWN=j
LEFT=h
RIGHT=l
2006-12-13 11:26:38 +01:00
WMII_FONT='-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*'
# colors are text, bg, border
WMII_NORMCOLORS='#222222 #eeeeee #666666'
WMII_SELCOLORS='#444444 #bbbbbb #556088'
WMII_FOCUSCOLORS='#ffffff #335577 #447799'
WMII_BACKGROUND='#333333'
2006-12-21 14:26:09 +01:00
DMENU="dmenu -b -fn $WMII_FONT -nb #eeeeee -nf #222222 -sb #335577 -sf #ffffff"
WMII_TERM="xterm"
2006-02-25 19:36:53 +01:00
export DMENU WMII_FONT WMII_FOCUSCOLORS WMII_SELCOLORS WMII_NORMCOLORS WMII_TERM
2006-10-30 09:54:22 +01:00
# stop any running instances of wmiirc
echo Start wmiirc | wmiir write /event || exit 1
2006-03-22 17:58:04 +01:00
2006-02-25 19:36:53 +01:00
# WM CONFIGURATION
wmiir write /ctl << EOF
font $WMII_FONT
focuscolors $WMII_FOCUSCOLORS
selcolors $WMII_SELCOLORS
normcolors $WMII_NORMCOLORS
grabmod $MODKEY
2006-06-21 14:48:39 -04:00
border 2
EOF
# COLUMN RULES
wmiir write /colrules <<EOF
/1/ -> 50+50
EOF
2006-02-25 19:36:53 +01:00
# TAGGING RULES
wmiir write /tagrules <<EOF
2006-04-11 18:45:40 +02:00
/XMMS.*/ -> ~
/Gimp.*/ -> gimp
/MPlayer.*/ -> ~
2006-04-13 14:58:22 +02:00
/.*/ -> !
/.*/ -> 1
EOF
2006-02-25 19:36:53 +01:00
# MISC
xsetroot -solid $WMII_BACKGROUND
`conf_which status` &
PROGS_FILE="$WMII_NS_DIR/.dmenu.proglist"
ACTIONS_DIRS=`echo "$WMII_CONFPATH" | tr : ' '`
proglist `echo "$PATH" | tr : ' '` >$PROGS_FILE &
2006-02-25 19:36:53 +01:00
# SHORTCUTS
wmiir write /keys <<EOF
$MODKEY-$LEFT
$MODKEY-$RIGHT
$MODKEY-$DOWN
$MODKEY-$UP
$MODKEY-space
$MODKEY-d
$MODKEY-f
$MODKEY-s
$MODKEY-m
$MODKEY-a
$MODKEY-p
2006-04-11 15:32:03 +02:00
$MODKEY-t
$MODKEY-0
2006-03-05 23:38:50 +01:00
$MODKEY-1
$MODKEY-2
$MODKEY-3
$MODKEY-4
$MODKEY-5
$MODKEY-6
$MODKEY-7
$MODKEY-8
$MODKEY-9
2006-04-11 15:32:03 +02:00
$MODKEY-Return
$MODKEY-Shift-$LEFT
$MODKEY-Shift-$RIGHT
$MODKEY-Shift-$UP
$MODKEY-Shift-$DOWN
$MODKEY-Shift-space
$MODKEY-Shift-c
$MODKEY-Shift-t
$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
2006-02-25 19:36:53 +01:00
# TAG BAR
wmiir ls /lbar |
2006-06-29 16:00:07 -04:00
while read bar
do
wmiir remove "/lbar/$bar"
done
seltag="`wmiir read /tag/sel/ctl 2>/dev/null`"
wmiir ls /tag | sed -e 's|/$||; /^sel$/d' |
2006-06-29 16:00:07 -04:00
while read tag
do
if [ "X$tag" = "X$seltag" ]; then
echo "$WMII_FOCUSCOLORS" "$tag" | wmiir create "/lbar/$tag"
else
echo "$WMII_NORMCOLORS" "$tag" | wmiir create "/lbar/$tag"
fi
done
2006-02-25 19:36:53 +01:00
# EVENT LOOP
wmiir read /event 2>/dev/null |
2006-02-25 19:36:53 +01:00
while read event
do
set -f
2006-02-25 19:36:53 +01:00
set -- $event
set +f
2006-02-25 19:36:53 +01:00
type="$1"; shift
parms="$@"
2006-02-25 19:36:53 +01:00
case "$type" in
Start)
if test $1 == "wmiirc"
then
2006-03-22 16:05:12 +01:00
exit
fi;;
CreateTag)
echo "$WMII_NORMCOLORS" "$parms" | wmiir create "/lbar/$parms"
;;
DestroyTag)
wmiir remove "/lbar/$parms"
;;
FocusTag)
xwrite "/lbar/$parms" "$WMII_FOCUSCOLORS" "$parms"
;;
UnfocusTag)
xwrite "/lbar/$parms" "$WMII_NORMCOLORS" "$parms"
;;
LeftBarClick)
shift
xwrite /ctl view "$@";;
Key)
2006-02-25 19:36:53 +01:00
case "$1" in
$MODKEY-$LEFT)
2006-06-19 18:25:49 -04:00
xwrite /tag/sel/ctl select left;;
$MODKEY-$RIGHT)
2006-06-19 18:25:49 -04:00
xwrite /tag/sel/ctl select right;;
$MODKEY-$DOWN)
xwrite /tag/sel/ctl select down;;
$MODKEY-$UP)
xwrite /tag/sel/ctl select up;;
$MODKEY-space)
2006-06-20 10:24:58 +02:00
xwrite /tag/sel/ctl select toggle;;
$MODKEY-d)
xwrite /tag/sel/ctl colmode sel default;;
$MODKEY-s)
xwrite /tag/sel/ctl colmode sel stack;;
$MODKEY-m)
xwrite /tag/sel/ctl colmode sel max;;
$MODKEY-f)
xwrite /tag/sel/0/sel/geom 0 0 0 0;;
$MODKEY-a)
2006-09-27 18:00:41 +02:00
`conf_which "\`proglist $ACTIONS_DIRS | $DMENU\`"` &;;
$MODKEY-p)
2006-10-10 09:25:42 +02:00
sh -c "`$DMENU <$PROGS_FILE`" &;;
2006-04-11 15:32:03 +02:00
$MODKEY-t)
tagsmenu /ctl view &;;
2006-03-05 23:38:50 +01:00
$MODKEY-[0-9])
2006-06-29 15:54:58 -04:00
xwrite /ctl view "`echo $1 | sed 's/.*-//'`";;
2006-04-11 15:32:03 +02:00
$MODKEY-Return)
$WMII_TERM &;;
2006-04-12 15:29:03 +02:00
$MODKEY-Shift-$LEFT)
2006-06-19 18:25:49 -04:00
xwrite /tag/sel/ctl send sel left;;
2006-04-12 15:29:03 +02:00
$MODKEY-Shift-$RIGHT)
2006-06-19 18:25:49 -04:00
xwrite /tag/sel/ctl send sel right;;
$MODKEY-Shift-$DOWN)
2006-06-19 13:18:09 +02:00
xwrite /tag/sel/ctl send sel down;;
$MODKEY-Shift-$UP)
2006-06-19 13:18:09 +02:00
xwrite /tag/sel/ctl send sel up;;
$MODKEY-Shift-space)
2006-06-19 13:18:09 +02:00
xwrite /tag/sel/ctl send sel toggle;;
$MODKEY-Shift-c)
2006-06-20 10:24:58 +02:00
xwrite /client/sel/ctl kill;;
$MODKEY-Shift-t)
tagsmenu "/client/`wmiir read /client/sel/ctl`/tags" &;;
$MODKEY-Shift-[0-9])
xwrite /client/sel/tags "`echo $1 | sed 's/.*-//'`";;
2006-02-25 19:36:53 +01:00
esac;;
esac
done &