[hackers] [wmii] Added wmiiloop(1) and wmiiloop.1 to handle experimantal awk-based wmiirc.

From: Kris Maglione <jg_AT_suckless.org>
Date: Fri Feb 23 00:33:01 2007

changeset: 1936:4fcd84cc5c45
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Thu Feb 22 18:32:23 2007 -0500
summary: Added wmiiloop(1) and wmiiloop.1 to handle experimantal awk-based wmiirc.

diff -r 349838d8b101 -r 4fcd84cc5c45 Makefile
--- a/Makefile Thu Feb 22 17:02:14 2007 -0500
+++ b/Makefile Thu Feb 22 18:32:23 2007 -0500
@@ -6,6 +6,8 @@ SRC = area.c bar.c client.c column.c dra
 SRC = area.c bar.c client.c column.c draw.c event.c frame.c fs.c \
         geom.c key.c main.c mouse.c rule.c printevent.c util.c view.c
 OBJ = ${SRC:.c=.o}
+MAN1 = wmii wmiir wmiiwm wmiiloop
+SCRIPTS = wmii wmiir wmiiloop
 
 all: options wmiiwm
 
@@ -48,39 +50,34 @@ dist: clean
         @rm -rf wmii-${VERSION}
 
 install: all
- @echo installing executable file to ${DESTDIR}${PREFIX}/bin
- @mkdir -p ${DESTDIR}${PREFIX}/bin
- @sed 's|CONFPREFIX|${CONFPREFIX}|g; s|CONFVERSION|${CONFVERSION}|g' <wmii >${DESTDIR}${PREFIX}/bin/wmii
- @cp -f wmiir ${DESTDIR}${PREFIX}/bin
+ @echo installing executable files to ${DESTDIR}${PREFIX}/bin
+ @mkdir -p -m 0755 ${DESTDIR}${PREFIX}/bin
+ @for i in ${SCRIPTS}; do \
+ sed 's|CONFPREFIX|${CONFPREFIX}|g; s|CONFVERSION|${CONFVERSION}|g' < $$i >${DESTDIR}${PREFIX}/bin/$$i; \
+ chmod 755 ${DESTDIR}${PREFIX}/bin/$$i; \
+ done
         @cp -f wmiiwm ${DESTDIR}${PREFIX}/bin
- @chmod 755 ${DESTDIR}${PREFIX}/bin/wmii
- @chmod 755 ${DESTDIR}${PREFIX}/bin/wmiir
         @chmod 755 ${DESTDIR}${PREFIX}/bin/wmiiwm
         @echo installing scripts to ${DESTDIR}${CONFPREFIX}/wmii-${CONFVERSION}
- @mkdir -p ${DESTDIR}${CONFPREFIX}/wmii-${CONFVERSION}
+ @mkdir -p -m 0755 ${DESTDIR}${CONFPREFIX}/wmii-${CONFVERSION}
         @cd rc; for i in *; do \
                 sed 's|CONFPREFIX|${CONFPREFIX}|g' <$$i >${DESTDIR}${CONFPREFIX}/wmii-${CONFVERSION}/$$i; \
                 chmod 755 ${DESTDIR}${CONFPREFIX}/wmii-${CONFVERSION}/$$i; \
         done
         @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
- @mkdir -p ${DESTDIR}${MANPREFIX}/man1
- @sed "s/VERSION/${VERSION}/g; s|CONFPREFIX|${CONFPREFIX}|g" < wmii.1 > ${DESTDIR}${MANPREFIX}/man1/wmii.1
- @sed "s/VERSION/${VERSION}/g" < wmiir.1 > ${DESTDIR}${MANPREFIX}/man1/wmiir.1
- @sed "s/VERSION/${VERSION}/g" < wmiiwm.1 > ${DESTDIR}${MANPREFIX}/man1/wmiiwm.1
- @chmod 644 ${DESTDIR}${MANPREFIX}/man1/wmii.1
- @chmod 644 ${DESTDIR}${MANPREFIX}/man1/wmiir.1
- @chmod 644 ${DESTDIR}${MANPREFIX}/man1/wmiiwm.1
+ @mkdir -p -m 0755 ${DESTDIR}${MANPREFIX}/man1
+ @for i in ${MAN1:=.1}; do \
+ sed "s/VERSION/${VERSION}/g; s|CONFPREFIX|${CONFPREFIX}|g" < $$i > ${DESTDIR}${MANPREFIX}/man1/$$i; \
+ chmod 644 ${DESTDIR}${MANPREFIX}/man1/$$i; \
+ done
 
 uninstall:
- @echo removing executable file from ${DESTDIR}${PREFIX}/bin
- @rm -f ${DESTDIR}${PREFIX}/bin/wmii
- @rm -f ${DESTDIR}${PREFIX}/bin/wmiir
+ @echo removing executable files from ${DESTDIR}${PREFIX}/bin
+ @cd ${DESTDIR}${PREFIX}/bin && rm -f ${SCRIPTS}
         @rm -f ${DESTDIR}${PREFIX}/bin/wmiiwm
         @echo removing scripts from ${DESTDIR}${CONFPREFIX}/wmii-${CONFVERSION}
         @rm -rf ${DESTDIR}${CONFPREFIX}/wmii-${CONFVERSION}
         @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
- @rm -f ${DESTDIR}${MANPREFIX}/man1/wmii.1
- @rm -f ${DESTDIR}${MANPREFIX}/man1/wmiir.1
- @rm -f ${DESTDIR}${MANPREFIX}/man1/wmiiwm.1
+ @cd ${DESTDIR}${MANPREFIX}/man1 && rm -f ${MAN1:=.1}
 
 .PHONY: all options clean dist install uninstall
diff -r 349838d8b101 -r 4fcd84cc5c45 rc/newrc
--- a/rc/newrc Thu Feb 22 17:02:14 2007 -0500
+++ b/rc/newrc Thu Feb 22 18:32:23 2007 -0500
@@ -1,17 +1,7 @@
 #!/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
+# Configuration Variables
 MODKEY=Mod1
 UP=k
 DOWN=j
@@ -201,67 +191,4 @@ proglist $PATH >$PROGS_FILE &
 proglist $PATH >$PROGS_FILE &
 EOF
 
-} | 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
- }
- else if(arg[1] == "Action") {
- actions[arg[2]] = body
- }
- }
- // && !begin, /# Events/ {
- begin = 1
- print
- next
- }
- /^#/ && $2 != "Events", 0 {
- print
- next
- }
- /^(Event|Key|Action)[ \t]/ {
- addevent()
- split($0, arg)
- body = ""
- }
- /^[ \t]/ {
- body = body"\n"$0
- }
- END {
- for(key in keys)
- print key | writekeys
- close(writekeys)
- print "ACTIONS=\"\""
- for(action in actions) {
- gsub("\"", "\\\"", action)
- print "ACTIONS=\"$ACTIONS\n" action "\""
- print "Action-" action "() {" actions[action] "\n}"
- }
- 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()
- }
- }' | tee /dev/fd/2 | sh
+} | wmiiloop | sh
diff -r 349838d8b101 -r 4fcd84cc5c45 wmiiloop
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wmiiloop Thu Feb 22 18:32:23 2007 -0500
@@ -0,0 +1,67 @@
+#!/usr/bin/awk
+// && !begin, /# Events/ {
+ begin = 1
+ print
+ next
+}
+/^#/ && $2 != "Events", 0 {
+ print
+ next
+}
+
+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
+ }
+ else if(arg[1] == "Action") {
+ actions[arg[2]] = body
+ }
+}
+
+/^(Event|Key|Action)[ \t]/ {
+ addevent()
+ split($0, arg)
+ body = ""
+}
+/^[ \t]/ {
+ body = body"\n"$0
+}
+
+END {
+ for(key in keys)
+ print key | writekeys
+ close(writekeys)
+ print "ACTIONS=\"\""
+ for(action in actions) {
+ gsub("\"", "\\\"", action)
+ print "ACTIONS=\"$ACTIONS\n" action "\""
+ print "Action-" action "() {" actions[action] "\n}"
+ }
+ 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()
+ }
+}
diff -r 349838d8b101 -r 4fcd84cc5c45 wmiiloop.1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wmiiloop.1 Thu Feb 22 18:32:23 2007 -0500
@@ -0,0 +1,79 @@
+.TH WMIIR 1 wmii\-VERSION
+.SH NAME
+wmiiloop \- wmii event loop processor
+.SH SYNOPSIS
+.B cat
+.I events
+|
+.B wmiiloop
+|
+.B sh
+.br
+.SH DESCRIPTION
+.SS Overview
+.B wmiiloop
+is an awk script which preprocesses
+.BR sh (1)
+syntax to simplify writing a wmii event loop.
+
+.br
+.B eventloop
+sends any text up to the first line containing
+.I #
+.IR Events ,
+and any text after any line begining with
+.IR # ,
+directly to its standard output. Any other line is processed based
+on its first word, with every indented line after it taken as its
+.IR body .
+.TP 2
+.BI "Key " sequence
+The key sequence
+.I sequence
+is bound to its
+.IR body .
+.I sequence
+is written to
+.I /keys
+and
+.I body
+is executed, with
+.I $key
+set to
+.I sequence
+whenever the key is pressed.
+
+.TP 2
+.BI "Event " name
+Whenever an event with
+.I name
+is read from
+.IR /event ,
+.I body
+is executed, with
+.I $event
+set to
+.IR name ,
+and
+.I $[1\-9]
+set to further arguments.
+
+.TP 2
+.BI "Action " name
+A function called
+.BI Action\- name
+is created with
+.I body
+as its body, and
+.I name
+is added to the
+.I $ACTIONS
+variable.
+
+.SH SEE ALSO
+.BR wmii (1),
+.BR wmiir (1),
+.BR wmiiwm (1)
+.B PREFIX/etc/wmiirc
+
+http://www.cs.bell\-labs.com/sys/man/5/INDEX.html
Received on Fri Feb 23 2007 - 00:33:01 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:46 UTC