wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit b09c59fbc7ae881ba61618cc35ea4345978d87ef
parent da724b0c23a5fa4c11b50616ce1118a327eb875f
Author: Kris Maglione <jg@suckless.org>
Date:   Wed,  7 Mar 2007 10:38:31 -0500

New wmiirc/wmiiloop model that mawk shouldn't choke on.

Diffstat:
rc/wmiirc | 24+++++++++++++++++-------
wmii9rc | 2+-
wmiiloop | 51+++++++++++----------------------------------------
3 files changed, 29 insertions(+), 48 deletions(-)

diff --git a/rc/wmiirc b/rc/wmiirc @@ -38,19 +38,23 @@ wmiir write /tagrules <<EOF EOF # Event processing -{ -cat <<'EOF' # Status Bar Info status() { echo -n $(uptime | sed 's/.*://; s/,//g') '|' $(date) } +IFS='' +eval $({ +cat <<'EOF' # Events Event Start case "$1" in wmiirc) - exit;; - exac + exit; + esac +Event Key + fn=$(echo $@ | sed 's/[^a-zA-Z_0-9]/_/g') + Key_$fn $@ Event CreateTag echo "$WMII_NORMCOLORS" "$@" | wmiir create "/lbar/$@" Event DestroyTag @@ -143,8 +147,9 @@ Key $MODKEY-Shift-$i wmiir xwrite /client/sel/tags "\$(echo \$key | sed 's/.*-//')" EOF done +} | wmiiloop) +unset IFS -cat <<'EOF' # Functions proglist() { paths=$(echo "$@" | sed 'y/:/ /') @@ -183,7 +188,6 @@ Action() { PROGS_FILE="$WMII_NS_DIR/.proglist" Action status & proglist $PATH >$PROGS_FILE & -EOF xsetroot -solid "$WMII_BACKGROUND" & @@ -215,4 +219,9 @@ done # Stop any running instances of wmiirc echo Start wmiirc | wmiir write /event || exit 1 -} | wmiiloop | sh +wmiir read /event | +while read event; do + set -- $event + event=$1; shift + Event_$event $@ 2>/dev/null +done+ \ No newline at end of file diff --git a/wmii9rc b/wmii9rc @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -f RC="" for i in "$PLAN9" /usr/local/plan9 /usr/local/9 /opt/plan9 /opt/9 /usr/plan9 /usr/9; do if [ -d "$i" -a -x "$i/bin/rc" ]; then diff --git a/wmiiloop b/wmiiloop @@ -1,32 +1,19 @@ #!AWKPATH -f -/^#/ && $2 !~ /^Events|Actions|Key$/ || !begin, \ -/^#/ && $2 ~ /^(Events|Actions|Key)$/ { - begin = 1 - print - next -} - BEGIN { arg[1] = "Nop" writekeys = "wmiir write /keys" - readevent = "wmiir read /event" - print "ACTIONS=\"\"" + print "IFS=''" } function addevent() { - if(arg[1] == "Key") { - keys[arg[2]] = body - } - else if(arg[1] == "Event") { - events[arg[2]] = body - } - else if(arg[1] == "Action") { - action = arg[2]; - actions[action] = body - gsub("\"", "\\\"", action) - print "ACTIONS=\"$ACTIONS " action "\"" - print "Action_" action "() {" actions[action] "\n}" - } + if(arg[1] == Key) + keys[arg[1]] = 1; + + var = arg[1] "s" + print var "=\"$" var "\n" arg[1] "\"" + + gsub("[^a-zA-Z_0-9]", "_", arg[2]); + print arg[1] "_" arg[2] "() {" body "\n}" } /^(Event|Key|Action)[ \t]/ { @@ -39,24 +26,8 @@ function addevent() { } END { + addevent() for(key in keys) print key | writekeys - close(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 body - fflush() - } + close(writekeys); }