Wmii: Jump to named tag

The standard configuration in wmii where you can jump to the tag 3 by pressing Mod-3 and tagging a window with 3 by pressing Mod-Shift-3 is very convenient. But you quickly end up by not naming your tags but using the "names" 1-9 instead. I have changed my configurations slightly so Mod2-m jumps to the first tag starting with m (e.g. music) and Mod2-Shift-m tags the current window with the first tag starting with m.

These are my changes:

In .Xmodmap I have set Caps Lock to be mod4:

clear mod4
clear lock
add mod4 = Caps_Lock

in .wmii-3.5/wmiirc I have added this code in the begining:


tag_shift() {
tag=`wmiir ls /tag | sed 's/\/$//' | grep -m 1 ^$1`
xwrite /ctl view $tag
}
#
tag_select() {
tag=`wmiir ls /tag | sed 's/\/$//' | grep -m 1 ^$1`
xwrite /client/sel/tags $tag
}

And after the definition of MODKEY I have a definition for MODKEY2:

MODKEY=Mod3
MODKEY2=Mod4

I have made a loop to add all the keys to the 'wmiir write /keys', this I have just before 'wmiir write /keys':


#make AZ contain all letters from a to z
AZ=`perl -e 'foreach ("a".."z") {print; print " "}'`
#
#
for letter in $AZ
do
MOD2LETTERS="$MOD2LETTERS$MODKEY2-$letter
"
MOD2SHIFT_LETTERS="$MOD2SHIFT_LETTERS$MODKEY2-Shift-$letter
"
done
#
# SHORTCUTS
wmiir write /keys << EOF
$MOD2LETTERS
$MOD2SHIFT_LETTERS
$MODKEY-$LEFT
...

And in the event loop I have this code:

$MODKEY2-[a-z])
tag_shift "`echo $1 | sed 's/.*-//'`";;
$MODKEY2-Shift-[a-z])
tag_select "`echo $1 | sed 's/.*-//'`";;

And that's it.