Skip to content
This repository has been archived by the owner on Jul 15, 2020. It is now read-only.

Commit

Permalink
Allow for wmiirc_local
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Maglione committed May 19, 2008
1 parent ed9fb21 commit 4ec3dc8
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 35 deletions.
67 changes: 42 additions & 25 deletions cmd/wmii.sh.sh
Expand Up @@ -4,10 +4,6 @@ if [ -z "$scriptname" ]; then
echo Start $wmiiscript | wmiir write /event 2>/dev/null ||
exit 1

Keys=""
Actions=""
Events=""

wi_nl='
'

Expand All @@ -21,10 +17,13 @@ _wi_script() {
function addevent() {
var = arg[1] "s"
for(i=2; i <= narg; i++) {
printf "%s=\"$%s\n%s\"\n", var, var, arg[i]
gsub("[^a-zA-Z_0-9]", "_", arg[i]);
if(body != "") {
printf "%s_%s() { %s\n }\n", arg[1], arg[i], body
if(body == "")
delete a[arg[1],arg[i]]
else
a[arg[1],arg[i]] = body
if(i == 2) {
# There's a bug here. Can you spot it?
gsub("[^a-zA-Z_0-9]", "_", arg[2]);
body = sprintf("%s_%s \"$@\"", arg[1], arg[2])
}
}
Expand All @@ -41,11 +40,31 @@ _wi_script() {
END {
addevent()
for(k in a) {
split(k, b, SUBSEP)
c[b[1]] = c[b[1]] b[2] "\n"
gsub("[^a-zA-Z_0-9]", "_", b[2]);
if(body != "")
printf "%s_%s() { %s\n }\n", b[1], b[2], a[k]
}
for(k in c) {
gsub("'", "'\"'\"'", c[k])
printf "%ss='%s'\n", k, c[k]
}
}
!
}

_wi_text() {
cat <<'!'
Event Start
if [ "$1" = "$wmiiscript" ]; then
exit
fi
Event Key
fn=$(echo "$@" | sed 's/[^a-zA-Z_0-9]/_/g')
Key_$fn "$@"
!
eval "cat <<!
$(sed "$_sed" | sed '/^[ ]/s/\([$`]\)/\\\1/g')
"
Expand All @@ -57,6 +76,7 @@ wi_events() {
_sed="s/^$2//"
shift 2
fi
#cho "$(_wi_text | awk "$(_wi_script)")"
eval "$(_wi_text | awk "$(_wi_script)")"
}

Expand Down Expand Up @@ -94,14 +114,21 @@ wi_proglist() {

wi_actions() {
{ wi_proglist $WMII_CONFPATH
wi_getfuns Action
echo -n "$Actions"
} | sort | uniq
}

conf_which() {
which=$(which which)
prog=$(PATH="$WMII_CONFPATH" $which $1); shift
[ -n "$prog" ] && $prog "$@"
wi_runconf() {
sflag=""; if [ "$1" = -s ]; then sflag=1; shift; fi
which="$(which which)"
prog=$(PATH="$WMII_CONFPATH" "$which" -- $1 2>/dev/null); shift
if [ -n "$prog" ]; then
if [ -z "$sflag" ]
then "$prog" "$@"
else . "$prog"
fi
else return 1
fi
}

wi_script() {
Expand All @@ -120,7 +147,7 @@ wi_runcmd() {
shift
set -- wihack -tags $(wmiir read /tag/sel/ctl | sed 1q) "$*"
fi
eval exec $* &
eval exec "$*" &
}

wi_tags() {
Expand All @@ -141,21 +168,11 @@ wi_eventloop() {
done 2>/dev/null
}

wi_events <<'!'
Event Start
if [ "$1" = "$wmiiscript" ]; then
exit
fi
Event Key
fn=$(echo "$@" | sed 's/[^a-zA-Z_0-9]/_/g')
Key_$fn "$@"
!

Action() {
action=$1; shift
if [ -n "$action" ]; then
Action_$action "$@" \
|| conf_which $action "$@"
|| wi_runconf $action "$@"
fi
}

6 changes: 3 additions & 3 deletions img/mkfile
Expand Up @@ -4,15 +4,15 @@ path=$PLAN9/bin $path
eps = wmii.eps

epsbox = `{sed -n '/^%%BoundingBox:/{s/.*://p; q;}' $eps}
iconwidth = 32
iconwidth = 154
iconscale = `{*=$epsbox; hoc -e $iconwidth/'('$3-' '$1')'}
iconheight = `{*=$epsbox; hoc -e '('$4-' '$2')*'$iconscale}
%.png: %.eps
* = `{hoc -e'-('$epsbox')'}
x = $1
y = $2
gs -q -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=$target -g$iconwidth'x'$iconheight - <<!
gs -q -dBATCH -dNOPAUSE -s'DEVICE=pngalpha' -s'OutputFile='$target -g$iconwidth'x'$iconheight - <<!
$iconscale $iconscale scale
$x $y translate
($eps) run
Expand All @@ -27,7 +27,7 @@ iconheight = `{*=$epsbox; hoc -e '('$4-' '$2')*'$iconscale}
* = `{hoc -e'-('$epsbox')'}
x = $1
y = $2
gs -q -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=$target -g$iconwidth'x'$iconheight - <<!
gs -q -dBATCH -dNOPAUSE -s'DEVICE=pngalpha' -s'OutputFile='$target -g$iconwidth'x'$iconheight - <<!
$iconscale $iconscale scale
$x $y translate
($eps) run
Expand Down
Binary file modified img/wmii.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion rc/rc.wmii.rc
Expand Up @@ -206,7 +206,7 @@ key $MODKEY-Shift-c || fn $key {
key $MODKEY-a || fn $key {
Action `{wi_actions | wi_menu} &}
key $MODKEY-p || fn $key {
ifs=() { wi_runcmd -t `{wi_menu <$progs_file} & }}
ifs=() { wi_runcmd `{wi_menu <$progs_file} & }}
key $MODKEY-Return || fn $key {
wi_runcmd $WMII_TERM &}

Expand Down
21 changes: 15 additions & 6 deletions rc/wmiirc.sh
Expand Up @@ -22,8 +22,8 @@ WMII_BACKGROUND='#333333'
WMII_FONT='-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*'

set -- $(echo $WMII_NORMCOLORS $WMII_FOCUSCOLORS)
WMII_MENU='dmenu -b -fn "$WMII_FONT" -nf '"'$1' -nb '$2' -sf '$4' -sb '$5'"
WMII_9MENU='wmii9menu -font "$WMII_FONT" -nf '"'$1' -nb '$2' -sf '$4' -sb '$5' -br '$6'"
WMII_MENU="dmenu -b -fn '\$WMII_FONT' -nf '$1' -nb '$2' -sf '$4' -sb '$5'"
WMII_9MENU="wmii9menu -font '\$WMII_FONT' -nf '$1' -nb '$2' -sf '$4' -sb '$5' -br '$6'"
WMII_TERM="xterm"

# Column Rules
Expand All @@ -42,10 +42,13 @@ status() {
echo -n $(uptime | sed 's/.*://; s/,//g') '|' $(date)
}

wi_runconf -s wmiirc_local

echo $WMII_NORMCOLORS | wmiir create $noticebar

# Event processing
wi_events -s ' ' <<'!'
events="$(
sed 's/^ //' <<'!'
# Events
Event CreateTag
echo "$WMII_NORMCOLORS" "$@" | wmiir create "/lbar/$@"
Expand Down Expand Up @@ -162,13 +165,19 @@ wi_events -s ' ' <<'!'
wmiir xwrite /tag/sel/ctl send sel up
!
for i in 0 1 2 3 4 5 6 7 8 9; do
wi_events -s ' ' <<!
sed 's/^ //' <<!
Key $MODKEY-$i
wmiir xwrite /ctl view "$i"
Key $MODKEY-Shift-$i
wmiir xwrite /client/sel/tags "$i"
!
done
)"
wi_events <<!
$events
$local_events
!
unset events local_events

# WM Configuration
wmiir write /ctl <<!
Expand All @@ -190,10 +199,10 @@ Action status &
wi_proglist $PATH >$progsfile &

# Setup Tag Bar
OIFS="$IFS"; IFS="$wi_nl"
IFS="$wi_nl"
wmiir rm $(wmiir ls /lbar | sed 's,^,/lbar/,')
seltag=$(wmiir read /tag/sel/ctl | sed 1q)
IFS="$OIFS"
unset IFS
wi_tags | while read tag
do
if [ "$tag" = "$seltag" ]; then
Expand Down

0 comments on commit 4ec3dc8

Please sign in to comment.