[hackers] [wmii] Add showkeys action to shell wmiirc || Kris Maglione

From: <hg_AT_suckless.org>
Date: Sat, 3 Oct 2009 03:02:39 +0000 (UTC)

changeset: 2518:0f5641b7c743
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Fri Oct 02 23:02:01 2009 -0400
files: cmd/wmii.sh.sh rc/wmiirc.sh
description:
Add showkeys action to shell wmiirc

diff -r 1fb4c1987676 -r 0f5641b7c743 cmd/wmii.sh.sh
--- a/cmd/wmii.sh.sh Fri Oct 02 22:03:54 2009 -0400
+++ b/cmd/wmii.sh.sh Fri Oct 02 23:02:01 2009 -0400
@@ -13,9 +13,10 @@
                 arg[1] = "Nop"
                 narg = 1;
                 body = "";
+ keyhelp = ""
         }
         function quote(s) {
- gsub(/"'"/, "'\\''", s)
+ gsub(/'/, "'\\''", s)
                 return "'" s "'"
         }
         function addevent() {
@@ -32,13 +33,22 @@
                         }
                 }
         }
+ /^(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 @@
                         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 @@
                         printf "case $%s in\n%s\n*) return 1\nesac\n", tolower(k), d[k]
                         printf "}\n"
                 }
+ print "KeysHelp=" quote(keyhelp)
         }
 !
 }
diff -r 1fb4c1987676 -r 0f5641b7c743 rc/wmiirc.sh
--- a/rc/wmiirc.sh Fri Oct 02 22:03:54 2009 -0400
+++ b/rc/wmiirc.sh Fri Oct 02 23:02:01 2009 -0400
@@ -115,6 +115,10 @@
         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 @@
                         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 @@
                         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
Received on Sat Oct 03 2009 - 03:02:39 UTC

This archive was generated by hypermail 2.2.0 : Sat Oct 03 2009 - 03:12:06 UTC