mirror of
https://github.com/0intro/wmii
synced 2024-11-22 22:02:30 +03:00
198 lines
4.1 KiB
Bash
198 lines
4.1 KiB
Bash
#!/bin/sh
|
|
# Configure wmii
|
|
|
|
# Configuration Variables
|
|
MODKEY=Mod1
|
|
UP=k
|
|
DOWN=j
|
|
LEFT=h
|
|
RIGHT=l
|
|
|
|
# Colors tuples are "<text> <background> <border>"
|
|
WMII_NORMCOLORS='#222222 #5FBF77 #2A7F3F'
|
|
WMII_FOCUSCOLORS='#ffffff #153F1F #2A7F3F'
|
|
WMII_BACKGROUND='#333333'
|
|
WMII_FONT='-*-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*'
|
|
|
|
WMII_TERM="xterm"
|
|
WMII_MENU="dmenu -b -fn '$WMII_FONT' -nb '#5FBF77' -nf '#222222' -sb '#153F1F' -sf '#ffffff'"
|
|
export WMII_MENU WMII_FONT WMII_FOCUSCOLORS WMII_SELCOLORS WMII_NORMCOLORS WMII_TERM
|
|
|
|
# Column Rules
|
|
wmiir write /colrules <<EOF
|
|
/.*/ -> 58+42
|
|
EOF
|
|
|
|
# Tagging Rules
|
|
wmiir write /tagrules <<EOF
|
|
/XMMS.*/ -> ~
|
|
/Gimp.*/ -> gimp
|
|
/MPlayer.*/ -> ~
|
|
/.*/ -> !
|
|
/.*/ -> 1
|
|
EOF
|
|
|
|
# Event processing
|
|
{
|
|
cat <<EOF
|
|
# Status Bar Info
|
|
status() {
|
|
echo -n \$(uptime | sed 's/.*://; s/,//g') '|' \$(date)
|
|
}
|
|
|
|
# Events
|
|
Event Start
|
|
case "\$1" in
|
|
wmiirc)
|
|
exit;;
|
|
exac
|
|
Event CreateTag
|
|
echo "$WMII_NORMCOLORS" "\$@" | wmiir create "/lbar/\$@"
|
|
Event DestroyTag
|
|
wmiir remove "/lbar/\$@"
|
|
Event FocusTag
|
|
wmiir xwrite "/lbar/\$@" "$WMII_FOCUSCOLORS" "\$@"
|
|
Event UnfocusTag
|
|
wmiir xwrite "/lbar/\$@" "$WMII_NORMCOLORS" "\$@"
|
|
Event UrgentTag
|
|
shift
|
|
wmiir xwrite "/lbar/\$@" "*\$@"
|
|
Event NotUrgentTag
|
|
shift
|
|
wmiir xwrite "/lbar/\$@" "\$@"
|
|
Event LeftBarClick
|
|
shift
|
|
wmiir xwrite /ctl view "\$@"
|
|
# Actions
|
|
Action quit
|
|
wmiir xwrite /ctl quit
|
|
Action rehash
|
|
proglist $PATH >$PROGS_FILE
|
|
Action status
|
|
if wmiir remove /rbar/status 2>/dev/null; then
|
|
sleep 2
|
|
fi
|
|
echo $WMII_NORMCOLORS | wmiir create /rbar/status
|
|
while status | wmiir write /rbar/status; do
|
|
sleep 1
|
|
done
|
|
# Key Bindings
|
|
Key $MODKEY-$LEFT
|
|
wmiir xwrite /tag/sel/ctl select left
|
|
Key $MODKEY-$RIGHT
|
|
wmiir xwrite /tag/sel/ctl select right
|
|
Key $MODKEY-$DOWN
|
|
wmiir xwrite /tag/sel/ctl select down
|
|
Key $MODKEY-$UP
|
|
wmiir xwrite /tag/sel/ctl select up
|
|
Key $MODKEY-space
|
|
wmiir xwrite /tag/sel/ctl select toggle
|
|
Key $MODKEY-d
|
|
wmiir xwrite /tag/sel/ctl colmode sel default
|
|
Key $MODKEY-s
|
|
wmiir xwrite /tag/sel/ctl colmode sel stack
|
|
Key $MODKEY-m
|
|
wmiir xwrite /tag/sel/ctl colmode sel max
|
|
Key $MODKEY-a
|
|
Action \$(actionlist | $WMII_MENU) &
|
|
Key $MODKEY-p
|
|
sh -c "\$($WMII_MENU <$PROGS_FILE)" &
|
|
Key $MODKEY-t
|
|
wmiir xwrite /ctl "view \$(tagsmenu)" &
|
|
Key $MODKEY-Return
|
|
$WMII_TERM &
|
|
Key $MODKEY-Shift-$LEFT
|
|
wmiir xwrite /tag/sel/ctl send sel left
|
|
Key $MODKEY-Shift-$RIGHT
|
|
wmiir xwrite /tag/sel/ctl send sel right
|
|
Key $MODKEY-Shift-$DOWN
|
|
wmiir xwrite /tag/sel/ctl send sel down
|
|
Key $MODKEY-Shift-$UP
|
|
wmiir xwrite /tag/sel/ctl send sel up
|
|
Key $MODKEY-Shift-space
|
|
wmiir xwrite /tag/sel/ctl send sel toggle
|
|
Key $MODKEY-Shift-c
|
|
wmiir xwrite /client/sel/ctl kill
|
|
Key $MODKEY-Shift-t
|
|
wmiir xwrite "/client/\$(wmiir read /client/sel/ctl)/tags" "\$(tagsmenu)" &
|
|
EOF
|
|
for i in 0 1 2 3 4 5 6 7 8 9; do
|
|
cat << EOF
|
|
Key $MODKEY-$i
|
|
wmiir xwrite /ctl view "\$(echo \$key | sed 's/.*-//')"
|
|
Key $MODKEY-Shift-$i
|
|
wmiir xwrite /client/sel/tags "\$(echo \$key | sed 's/.*-//')"
|
|
EOF
|
|
done
|
|
|
|
cat <<EOF
|
|
# Functions
|
|
proglist() {
|
|
paths=\$(echo "\$@" | sed 'y/:/ /')
|
|
ls -lL \$paths 2>/dev/null |
|
|
awk '\$1 ~ /^[^d].*x/ { print \$NF }' |
|
|
sort | uniq
|
|
}
|
|
|
|
actionlist() {
|
|
{
|
|
proglist $WMII_CONFPATH
|
|
echo \$ACTIONS | tr ' ' '\012'
|
|
} | sort | uniq
|
|
}
|
|
|
|
conf_which () {
|
|
echo \$(PATH="$WMII_CONFPATH:$PATH" which \$1) "\$@"
|
|
}
|
|
|
|
tagsmenu() {
|
|
wmiir ls /tag | sed "s|/||; /^sel\$/d" | $WMII_MENU
|
|
}
|
|
|
|
Action() {
|
|
action=\$1; shift
|
|
if [ -n "\$action" ]; then
|
|
Action-\$action \$@ || \$(conf_which "\$action") \$@
|
|
fi
|
|
}
|
|
|
|
# Misc
|
|
PROGS_FILE="$WMII_NS_DIR/.proglist"
|
|
Action status &
|
|
proglist $PATH >$PROGS_FILE &
|
|
EOF
|
|
|
|
xsetroot -solid "$WMII_BACKGROUND" &
|
|
|
|
# WM Configuration
|
|
wmiir write /ctl << EOF
|
|
font $WMII_FONT
|
|
focuscolors $WMII_FOCUSCOLORS
|
|
normcolors $WMII_NORMCOLORS
|
|
grabmod $MODKEY
|
|
border 1
|
|
EOF
|
|
|
|
# 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
|
|
|
|
# Stop any running instances of wmiirc
|
|
echo Start wmiirc | wmiir write /event || exit 1
|
|
|
|
} | wmiiloop | tee /dev/fd/2 | sh
|