commit e1e4450a412ee8e9b0aba4ed6cb06a0f25a89d6c parent 3d589a857307f3578c5940b062994d08e3156b6f Author: Kris Maglione <jg@suckless.org> Date: Thu, 22 Feb 2007 15:06:59 -0500 Added experimental awk-based wmiirc in rc/newrc Diffstat:
| rc/newrc | | | 223 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 223 insertions(+), 0 deletions(-)
diff --git a/rc/newrc b/rc/newrc @@ -0,0 +1,223 @@ +#!/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 #5FBF77 #2A7F3F' +WMII_FOCUSCOLORS='#ffffff #153F1F #2A7F3F' +WMII_BACKGROUND='#333333' + +WMII_MENU="dmenu -b -fn '$WMII_FONT' -nb '#5FBF77' -nf '#222222' -sb '#153F1F' -sf '#ffffff'" +WMII_TERM="xterm" + +export WMII_MENU 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 + +PROGS_FILE="$WMII_NS_DIR/.dmenu.proglist" +ACTIONS_DIRS="$(echo "$WMII_CONFPATH" | sed 'y/:/ /')" + +{ cat <<EOF +Event Start + if test "\$1" = "wmiirc" + then + exit + fi +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 "\$@" +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 + \$(conf_which "\$(proglist $ACTIONS_DIRS | $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 +} | awk ' +# Event Loop + BEGIN { + arg[1] = "Nop" + writekeys = "wmiir write /keys" + readevent = "wmiir read /event" + } + function addevent() { + if(arg[1] == "Key") { + keys[arg[2]] = body + } + else if(arg[1] == "Event") { + events[arg[2]] = body + } + } + /^(Event|Key)[ \t]/ { + addevent() + split($0, arg) + body = "" + } + /^[ \t]/ { + body = body"\n"$0 + } + END { + for(key in keys) + print key | writekeys + while(readevent | getline) { + split($0, arg) + sub("^[a-zA-Z]+[ \t]+", "") + print "set -f" + if(arg[1] == "Key") { + sub("^[^ \t]+", "") + print "key=\"" arg[2] "\"" + body = keys[arg[2]] + } + else { + print "event=\"" arg[1] "\"" + body = events[arg[1]] + } + print "set -- " $0 + print "set +f" + print body + fflush() + } + }' | { + cat << EOF +# FUNCTIONS +proglist() { + ls -lL \$@ 2>/dev/null | + awk '\$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() { + wmiir ls /tag | sed "s|/||; /^sel\$/d" | $WMII_MENU +} + +# MISC +\$(conf_which status) & +xsetroot -solid "$WMII_BACKGROUND" & +proglist $(echo "$PATH" | sed 'y/:/ /') >$PROGS_FILE & + +# Stop any running instances of wmiirc +if ! echo Start wmiirc | wmiir write /event +then + exit 1 +fi + +# 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 +EOF + cat + } | tee /dev/fd/2 | sh