mirror of https://github.com/0intro/wmii
230 lines
4.5 KiB
Bash
230 lines
4.5 KiB
Bash
#!/bin/sh
|
|
# Configure wmii
|
|
|
|
# Contents
|
|
# Configuration Variables
|
|
# WM Configuration
|
|
# Column Rules
|
|
# Tagging Rules
|
|
# Utility Functions
|
|
# Tag Bar Setup
|
|
# List of Bound Keys
|
|
# Event Processing Loop
|
|
|
|
# CONFIGURATION VARIABLES
|
|
MODKEY=Mod1
|
|
UP=k
|
|
DOWN=j
|
|
LEFT=h
|
|
RIGHT=l
|
|
|
|
WMII_FONT='-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*'
|
|
# Colors tuples are "<text> <background> <border>"
|
|
WMII_NORMCOLORS='#222222 #eeeeee #666666'
|
|
WMII_FOCUSCOLORS='#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_FOCUSCOLORS WMII_SELCOLORS WMII_NORMCOLORS WMII_TERM
|
|
|
|
# WM CONFIGURATION
|
|
wmiir write /ctl << EOF
|
|
font $WMII_FONT
|
|
focuscolors $WMII_FOCUSCOLORS
|
|
normcolors $WMII_NORMCOLORS
|
|
grabmod $MODKEY
|
|
border 1
|
|
EOF
|
|
|
|
# COLUMN RULES
|
|
wmiir write /colrules <<EOF
|
|
/.*/ -> 58+42
|
|
EOF
|
|
|
|
# TAGGING RULES
|
|
wmiir write /tagrules <<EOF
|
|
/XMMS.*/ -> ~
|
|
/Gimp.*/ -> gimp
|
|
/MPlayer.*/ -> ~
|
|
/.*/ -> !
|
|
/.*/ -> 1
|
|
EOF
|
|
|
|
# FUNCTIONS
|
|
proglist() {
|
|
ls -lL "$@" 2>/dev/null | awk 'NF>2 && $1 ~ /^[^d].*x/ {print $NF}' | sort | uniq
|
|
}
|
|
|
|
conf_which () {
|
|
prog=$1; shift
|
|
if [ -n "$prog" ]; then
|
|
echo `PATH="$WMII_CONFPATH:$PATH" which $prog` "$@"
|
|
fi
|
|
}
|
|
|
|
tagsmenu() {
|
|
tag=`wmiir read /tag/sel/ctl`
|
|
wmiir ls /tag | sed "s|/||; /^sel\$/d" | $DMENU
|
|
}
|
|
|
|
# MISC
|
|
PROGS_FILE="$WMII_NS_DIR/.dmenu.proglist"
|
|
ACTIONS_DIRS=`echo "$WMII_CONFPATH" | tr : ' '`
|
|
|
|
`conf_which status` &
|
|
xsetroot -solid $WMII_BACKGROUND &
|
|
proglist `echo "$PATH" | sed 'y/:/ /'` >$PROGS_FILE &
|
|
|
|
# Stop any running instances of wmiirc
|
|
echo Start wmiirc | wmiir write /event || exit 1
|
|
|
|
# SETUP TAG BAR
|
|
wmiir ls /lbar |
|
|
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' |
|
|
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
|
|
|
|
# BOUND KEYS
|
|
wmiir write /keys <<EOF
|
|
$MODKEY-$LEFT
|
|
$MODKEY-$RIGHT
|
|
$MODKEY-$DOWN
|
|
$MODKEY-$UP
|
|
$MODKEY-space
|
|
$MODKEY-d
|
|
$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
|
|
|
|
# EVENT LOOP
|
|
wmiir 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" | wmiir create "/lbar/$parms"
|
|
;;
|
|
DestroyTag)
|
|
wmiir remove "/lbar/$parms"
|
|
;;
|
|
FocusTag)
|
|
wmiir xwrite "/lbar/$parms" "$WMII_FOCUSCOLORS" "$parms"
|
|
;;
|
|
UnfocusTag)
|
|
wmiir xwrite "/lbar/$parms" "$WMII_NORMCOLORS" "$parms"
|
|
;;
|
|
UrgentTag)
|
|
shift
|
|
wmiir xwrite "/lbar/$@" "*$@"
|
|
;;
|
|
NotUrgentTag)
|
|
shift
|
|
wmiir xwrite "/lbar/$@" "$@"
|
|
;;
|
|
LeftBarClick)
|
|
shift
|
|
wmiir xwrite /ctl view "$@";;
|
|
Key)
|
|
key="$1"
|
|
case "$key" in
|
|
$MODKEY-$LEFT)
|
|
wmiir xwrite /tag/sel/ctl select left;;
|
|
$MODKEY-$RIGHT)
|
|
wmiir xwrite /tag/sel/ctl select right;;
|
|
$MODKEY-$DOWN)
|
|
wmiir xwrite /tag/sel/ctl select down;;
|
|
$MODKEY-$UP)
|
|
wmiir xwrite /tag/sel/ctl select up;;
|
|
$MODKEY-space)
|
|
wmiir xwrite /tag/sel/ctl select toggle;;
|
|
$MODKEY-d)
|
|
wmiir xwrite /tag/sel/ctl colmode sel default;;
|
|
$MODKEY-s)
|
|
wmiir xwrite /tag/sel/ctl colmode sel stack;;
|
|
$MODKEY-m)
|
|
wmiir xwrite /tag/sel/ctl colmode sel max;;
|
|
$MODKEY-a)
|
|
`conf_which "$(proglist $ACTIONS_DIRS | $DMENU)"` &;;
|
|
$MODKEY-p)
|
|
sh -c "`$DMENU <$PROGS_FILE`" &;;
|
|
$MODKEY-t)
|
|
wmiir xwrite /ctl "view `tagsmenu`" &;;
|
|
$MODKEY-[0-9])
|
|
wmiir xwrite /ctl view "`echo $key | sed 's/.*-//'`";;
|
|
$MODKEY-Return)
|
|
$WMII_TERM &;;
|
|
$MODKEY-Shift-$LEFT)
|
|
wmiir xwrite /tag/sel/ctl send sel left;;
|
|
$MODKEY-Shift-$RIGHT)
|
|
wmiir xwrite /tag/sel/ctl send sel right;;
|
|
$MODKEY-Shift-$DOWN)
|
|
wmiir xwrite /tag/sel/ctl send sel down;;
|
|
$MODKEY-Shift-$UP)
|
|
wmiir xwrite /tag/sel/ctl send sel up;;
|
|
$MODKEY-Shift-space)
|
|
wmiir xwrite /tag/sel/ctl send sel toggle;;
|
|
$MODKEY-Shift-c)
|
|
wmiir xwrite /client/sel/ctl kill;;
|
|
$MODKEY-Shift-t)
|
|
wmiir xwrite "/client/`wmiir read /client/sel/ctl`/tags" "`tagsmenu`" &;;
|
|
$MODKEY-Shift-[0-9])
|
|
wmiir xwrite /client/sel/tags "`echo $key | sed 's/.*-//'`";;
|
|
esac;;
|
|
esac
|
|
done &
|