mirror of
https://github.com/0intro/wmii
synced 2024-11-22 22:02:30 +03:00
218 lines
4.2 KiB
Bash
218 lines
4.2 KiB
Bash
#!/bin/sh
|
|
# configure wmii
|
|
|
|
xwrite() {
|
|
file="$1"; shift
|
|
echo -n "$@" | ixpc write "$file"
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
tagsmenu() {
|
|
tag=`ixpc read /tag/sel/ctl`
|
|
tags=`ixpc 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
|
|
|
|
WMII_FONT='-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*'
|
|
# colors are text, bg, border
|
|
WMII_NORMCOLORS='#222222 #eeeeee #666666'
|
|
WMII_SELCOLORS='#ffffff #335577 #447799'
|
|
WMII_BACKGROUND='#333333'
|
|
|
|
DMENU="dmenu -b -fn $WMII_FONT -nb #eeeeee -nf #222222 -sb #335577 -sf #ffffff"
|
|
WMII_TERM="xterm"
|
|
|
|
export DMENU WMII_FONT WMII_SELCOLORS WMII_NORMCOLORS WMII_TERM
|
|
|
|
# stop any running instances of wmiirc
|
|
echo Start wmiirc | ixpc write /event || exit 1
|
|
|
|
# WM CONFIGURATION
|
|
ixpc write /ctl << EOF
|
|
font $WMII_FONT
|
|
selcolors $WMII_SELCOLORS
|
|
normcolors $WMII_NORMCOLORS
|
|
grabmod $MODKEY
|
|
border 2
|
|
EOF
|
|
|
|
# COLUMN RULES
|
|
ixpc write /colrules <<EOF
|
|
/1/ -> 50+50
|
|
EOF
|
|
|
|
# TAGGING RULES
|
|
ixpc write /tagrules <<EOF
|
|
/XMMS.*/ -> ~
|
|
/Gimp.*/ -> ~
|
|
/MPlayer.*/ -> ~
|
|
/.*/ -> !
|
|
/.*/ -> 1
|
|
EOF
|
|
|
|
# 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 &
|
|
|
|
# SHORTCUTS
|
|
ixpc 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
|
|
$MODKEY-t
|
|
$MODKEY-0
|
|
$MODKEY-1
|
|
$MODKEY-2
|
|
$MODKEY-3
|
|
$MODKEY-4
|
|
$MODKEY-5
|
|
$MODKEY-6
|
|
$MODKEY-7
|
|
$MODKEY-8
|
|
$MODKEY-9
|
|
$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
|
|
|
|
# TAG BAR
|
|
ixpc ls /lbar |
|
|
while read bar
|
|
do
|
|
ixpc remove "/lbar/$bar"
|
|
done
|
|
|
|
seltag="`ixpc read /tag/sel/ctl 2>/dev/null`"
|
|
ixpc ls /tag | sed -e 's,/$,,; /^sel$/d' |
|
|
while read tag
|
|
do
|
|
if [ "X$tag" = "X$seltag" ]; then
|
|
echo "$WMII_SELCOLORS" "$tag" | ixpc create "/lbar/$tag"
|
|
else
|
|
echo "$WMII_NORMCOLORS" "$tag" | ixpc create "/lbar/$tag"
|
|
fi
|
|
done
|
|
|
|
# EVENT LOOP
|
|
ixpc read /event 2>/dev/null |
|
|
while read event
|
|
do
|
|
set -f
|
|
set -- $event
|
|
set +f
|
|
type="$1"; shift
|
|
parms="$@"
|
|
case "$type" in
|
|
Start)
|
|
if test $1 == "wmiirc"
|
|
then
|
|
exit
|
|
fi;;
|
|
CreateTag)
|
|
echo "$WMII_NORMCOLORS" "$parms" | ixpc create "/lbar/$parms"
|
|
;;
|
|
DestroyTag)
|
|
ixpc remove "/lbar/$parms"
|
|
;;
|
|
FocusTag)
|
|
xwrite "/lbar/$parms" "$WMII_SELCOLORS" "$parms"
|
|
;;
|
|
UnfocusTag)
|
|
xwrite "/lbar/$parms" "$WMII_NORMCOLORS" "$parms"
|
|
;;
|
|
LeftBarClick)
|
|
shift
|
|
xwrite /ctl view "$@";;
|
|
Key)
|
|
case "$1" in
|
|
$MODKEY-$LEFT)
|
|
xwrite /tag/sel/ctl select left;;
|
|
$MODKEY-$RIGHT)
|
|
xwrite /tag/sel/ctl select right;;
|
|
$MODKEY-$DOWN)
|
|
xwrite /tag/sel/ctl select down;;
|
|
$MODKEY-$UP)
|
|
xwrite /tag/sel/ctl select up;;
|
|
$MODKEY-space)
|
|
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)
|
|
`conf_which "\`proglist $ACTIONS_DIRS | $DMENU\`"` &;;
|
|
$MODKEY-p)
|
|
sh -c "`$DMENU <$PROGS_FILE`" &;;
|
|
$MODKEY-t)
|
|
tagsmenu /ctl view &;;
|
|
$MODKEY-[0-9])
|
|
xwrite /ctl view "`echo $1 | sed 's/.*-//'`";;
|
|
$MODKEY-Return)
|
|
$WMII_TERM &;;
|
|
$MODKEY-Shift-$LEFT)
|
|
xwrite /tag/sel/ctl send sel left;;
|
|
$MODKEY-Shift-$RIGHT)
|
|
xwrite /tag/sel/ctl send sel right;;
|
|
$MODKEY-Shift-$DOWN)
|
|
xwrite /tag/sel/ctl send sel down;;
|
|
$MODKEY-Shift-$UP)
|
|
xwrite /tag/sel/ctl send sel up;;
|
|
$MODKEY-Shift-space)
|
|
xwrite /tag/sel/ctl send sel toggle;;
|
|
$MODKEY-Shift-c)
|
|
xwrite /client/sel/ctl kill;;
|
|
$MODKEY-Shift-t)
|
|
tagsmenu "/client/`ixpc read /client/sel/ctl`/tags" &;;
|
|
$MODKEY-Shift-[0-9])
|
|
xwrite /client/sel/tags "`echo $1 | sed 's/.*-//'`";;
|
|
esac;;
|
|
esac
|
|
done &
|