mirror of
https://github.com/0intro/wmii
synced 2024-11-22 05:42:05 +03:00
Added wmiiloop(1) and wmiiloop.1 to handle experimantal awk-based wmiirc.
This commit is contained in:
parent
fb8b463288
commit
f56a70589e
37
Makefile
37
Makefile
@ -6,6 +6,8 @@ include config.mk
|
||||
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
|
||||
|
77
rc/newrc
77
rc/newrc
@ -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 @@ xsetroot -solid "$WMII_BACKGROUND" &
|
||||
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
|
||||
|
67
wmiiloop
Normal file
67
wmiiloop
Normal file
@ -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()
|
||||
}
|
||||
}
|
79
wmiiloop.1
Normal file
79
wmiiloop.1
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user