wmii

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

commit 4ec3dc80e6c7ea2da42f735351a0ba6c0fb88a52
parent ed9fb216e68b3f7f41c5ee74e508185f394ae5ec
Author: Kris Maglione <jg@suckless.org>
Date:   Mon, 19 May 2008 19:26:43 -0400

Allow for wmiirc_local

Diffstat:
cmd/wmii.sh.sh | 67++++++++++++++++++++++++++++++++++++++++++-------------------------
img/mkfile | 6+++---
img/wmii.png | 0
rc/rc.wmii.rc | 2+-
rc/wmiirc.sh | 21+++++++++++++++------
5 files changed, 61 insertions(+), 35 deletions(-)

diff --git a/cmd/wmii.sh.sh b/cmd/wmii.sh.sh @@ -4,10 +4,6 @@ if [ -z "$scriptname" ]; then echo Start $wmiiscript | wmiir write /event 2>/dev/null || exit 1 -Keys="" -Actions="" -Events="" - wi_nl=' ' @@ -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]) } } @@ -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') " @@ -57,6 +76,7 @@ wi_events() { _sed="s/^$2//" shift 2 fi + #cho "$(_wi_text | awk "$(_wi_script)")" eval "$(_wi_text | awk "$(_wi_script)")" } @@ -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() { @@ -120,7 +147,7 @@ wi_runcmd() { shift set -- wihack -tags $(wmiir read /tag/sel/ctl | sed 1q) "$*" fi - eval exec $* & + eval exec "$*" & } wi_tags() { @@ -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 } diff --git a/img/mkfile b/img/mkfile @@ -4,7 +4,7 @@ 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} @@ -12,7 +12,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 @@ -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 diff --git a/img/wmii.png b/img/wmii.png Binary files differ. diff --git a/rc/rc.wmii.rc b/rc/rc.wmii.rc @@ -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 &} diff --git a/rc/wmiirc.sh b/rc/wmiirc.sh @@ -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 @@ -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/$@" @@ -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 <<! @@ -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