wmii

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

commit 53cdd19a9db16c1feb306ce05c768a46823e246a
parent ef58c489fef5ede8f87e575405f90f7255e753aa
Author: Kris Maglione <jg@suckless.org>
Date:   Fri,  2 Oct 2009 23:02:01 -0400

Add showkeys action to shell wmiirc

Diffstat:
cmd/wmii.sh.sh | 19+++++++++++++++----
rc/wmiirc.sh | 112+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
2 files changed, 82 insertions(+), 49 deletions(-)

diff --git a/cmd/wmii.sh.sh b/cmd/wmii.sh.sh @@ -13,9 +13,10 @@ _wi_script() { arg[1] = "Nop" narg = 1; body = ""; + keyhelp = "" } function quote(s) { - gsub(/"'"/, "'\\''", s) + gsub(/'/, "'\\''", s) return "'" s "'" } function addevent() { @@ -32,13 +33,22 @@ _wi_script() { } } } + /^(Key)Group[ \t]/ { + sub(/^[^ \t]+[ \t]+/, "") + keyhelp = keyhelp "\n " $0 "\n" + } /^(Event|Key|Action|Menu)[ \t]/ { addevent() - split($0, arg) - narg = NF + split($0, tmp, /[ \t]+#[ \t]*/) + narg = split(tmp[1], arg) + if(arg[1] == "Key" && tmp[2]) + for (i=2; i <= narg; i++) + keyhelp = keyhelp sprintf(" %-20s %s\n", + arg[i], tmp[2]) body = "" } /^[ \t]/ { + sub(/^( |\t)/, "") body = body"\n"$0 } @@ -48,7 +58,7 @@ _wi_script() { split(k, b, SUBSEP) c[b[1]] = c[b[1]] b[2] "\n" if(body != "") - d[b[1]] = d[b[1]] quote(b[2]) ")" a[k] ";;\n" + d[b[1]] = d[b[1]] quote(b[2]) ")" a[k] "\n;;\n" } for(k in c) printf "%ss=%s\n", k, quote(c[k]) @@ -58,6 +68,7 @@ _wi_script() { printf "case $%s in\n%s\n*) return 1\nesac\n", tolower(k), d[k] printf "}\n" } + print "KeysHelp=" quote(keyhelp) } ! } diff --git a/rc/wmiirc.sh b/rc/wmiirc.sh @@ -115,6 +115,10 @@ events() { Event LeftBarMouseDown wi_fnmenu LBar "$@" & # Actions + Action showkeys + xmessage -file - -fn ${WMII_FONT%%,*} <<EOF + $KeysHelp + EOF Action quit wmiir xwrite /ctl quit Action exec @@ -131,7 +135,63 @@ events() { sleep 1 done # Key Bindings - Key $MODKEY-Control-t + KeyGroup Moving around + Key $MODKEY-$LEFT # Select the client to the left + wmiir xwrite /tag/sel/ctl select left + Key $MODKEY-$RIGHT # Select the client to the right + wmiir xwrite /tag/sel/ctl select right + Key $MODKEY-$UP # Select the client above + wmiir xwrite /tag/sel/ctl select up + Key $MODKEY-$DOWN # Select the client below + wmiir xwrite /tag/sel/ctl select down + + Key $MODKEY-space # Toggle between floating and managed layers + wmiir xwrite /tag/sel/ctl select toggle + + KeyGroup Moving through stacks + Key $MODKEY-Control-$UP # Select the stack above + wmiir xwrite /taglsel/ctl select up stack + Key $MODKEY-Control-$DOWN # Select the stack below + wmiir xwrite /taglsel/ctl select down stack + + KeyGroup Moving clients around + Key $MODKEY-Shift-$LEFT # Move selected client to the left + wmiir xwrite /tag/sel/ctl send sel left + Key $MODKEY-Shift-$RIGHT # Move selected client to the right + wmiir xwrite /tag/sel/ctl send sel right + Key $MODKEY-Shift-$UP # Move selected client up + wmiir xwrite /tag/sel/ctl send sel up + Key $MODKEY-Shift-$DOWN # Move selected client down + wmiir xwrite /tag/sel/ctl send sel down + + Key $MODKEY-Shift-space # Toggle selected client between floating and managed layers + wmiir xwrite /tag/sel/ctl send sel toggle + + KeyGroup Client actions + Key $MODKEY-f # Toggle selected client's fullsceen state + wmiir xwrite /client/sel/ctl Fullscreen toggle + Key $MODKEY-Shift-c # Close client + wmiir xwrite /client/sel/ctl kill + + KeyGroup Changing column modes + Key $MODKEY-d # Set column to default mode + wmiir xwrite /tag/sel/ctl colmode sel default-max + Key $MODKEY-s # Set column to stack mode + wmiir xwrite /tag/sel/ctl colmode sel stack-max + Key $MODKEY-m # Set column to max mode + wmiir xwrite /tag/sel/ctl colmode sel stack+max + + KeyGroup Running programs + Key $MODKEY-a # Open wmii actions menu + action $(wi_actions | wimenu -h "${hist}.actions" -n $histnum) & + Key $MODKEY-p # Open program menu + eval wmiir setsid "$(wimenu -h "${hist}.progs" -n $histnum <$progsfile)" & + + Key $MODKEY-Return # Launch a terminal + eval wmiir setsid $WMII_TERM & + + KeyGroup Other + Key $MODKEY-Control-t # Toggle all other key bindings case $(wmiir read /keys | wc -l | tr -d ' \t\n') in 0|1) echo -n "$Keys" | wmiir write /keys @@ -140,57 +200,19 @@ events() { wmiir xwrite /keys $MODKEY-Control-t wmiir xwrite /ctl grabmod Mod3;; esac - Key $MODKEY-space - wmiir xwrite /tag/sel/ctl select toggle - Key $MODKEY-d - wmiir xwrite /tag/sel/ctl colmode sel default-max - Key $MODKEY-s - wmiir xwrite /tag/sel/ctl colmode sel stack-max - Key $MODKEY-m - wmiir xwrite /tag/sel/ctl colmode sel stack+max - Key $MODKEY-a - action $(wi_actions | wimenu -h "${hist}.actions" -n $histnum) & - Key $MODKEY-p - eval wmiir setsid "$(wimenu -h "${hist}.progs" -n $histnum <$progsfile)" & - Key $MODKEY-t + + KeyGroup Tag actions + Key $MODKEY-t # Change to another tag (tag=$(wi_tags | wimenu -h "${hist}.tags" -n 50) && wmiir xwrite /ctl view $tag) & - Key $MODKEY-Return - eval wmiir setsid $WMII_TERM & - Key $MODKEY-Shift-space - wmiir xwrite /tag/sel/ctl send sel toggle - Key $MODKEY-f - wmiir xwrite /client/sel/ctl Fullscreen toggle - Key $MODKEY-Shift-c - wmiir xwrite /client/sel/ctl kill - Key $MODKEY-Shift-t + Key $MODKEY-Shift-t # Retag the selected client c=$(wi_selclient) (tag=$(wi_tags | wimenu -h "${hist}.tags" -n 50) && wmiir xwrite /client/$c/tags $tag) & - Key $MODKEY-$LEFT - wmiir xwrite /tag/sel/ctl select left - Key $MODKEY-$RIGHT - wmiir xwrite /tag/sel/ctl select right - Key $MODKEY-$DOWN - wmiir xwrite /tag/sel/ctl select down - Key $MODKEY-$UP - wmiir xwrite /tag/sel/ctl select up - Key $MODKEY-Control-$DOWN - wmiir xwrite /tag/sel/ctl select down stack - Key $MODKEY-Control-$UP - wmiir xwrite /tag/sel/ctl select up stack - Key $MODKEY-Shift-$LEFT - wmiir xwrite /tag/sel/ctl send sel left - Key $MODKEY-Shift-$RIGHT - wmiir xwrite /tag/sel/ctl send sel right - Key $MODKEY-Shift-$DOWN - wmiir xwrite /tag/sel/ctl send sel down - Key $MODKEY-Shift-$UP - wmiir xwrite /tag/sel/ctl send sel up ! for i in 0 1 2 3 4 5 6 7 8 9; do cat <<! - Key $MODKEY-$i + Key $MODKEY-$i # Move to the numbered view wmiir xwrite /ctl view "$i" - Key $MODKEY-Shift-$i + Key $MODKEY-Shift-$i # Retag selected client with the numbered tag wmiir xwrite /client/sel/tags "$i" ! done