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

This commit is contained in:
Kris Maglione 2007-03-07 10:38:31 -05:00
parent da724b0c23
commit b09c59fbc7
3 changed files with 28 additions and 48 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}