[wmii] "AfterFocus" event request and retagging clients

From: <neptun_AT_gmail.com>
Date: Mon, 24 Apr 2006 21:14:16 +0000

Hello
I'd like wmii to have a new event that gets triggered after the client
gets focused. I believe this would give more freedom in customizing
wmii with scripts.

One of the uses that comes to mind would be having the title of the
selected client in a bar label thus making the individual titlebars of
clients optional. (It's my opinion that you can usually identify a
window by content and if you need more information about it wmii
provides easy ways to navigate to it and then you should have some context
information available. Actually I'd go even further and say that i'd
like the whole wmiibar optional (that is have a shortcut to show/hide
it) but I'm sure most will not agree so I'll drop it. As you might
noticed i do not like to much "decor" in the workspace (as in work
enviroment not the window manager meaning). My ideal setup would be
having only the windows contents visible and a way to show other usage
information on demand.

Another thing I'd like to use this event for is to create a script for
retaging the selected client (since as was discussed in an earlier
thread you can not identify a client yet unless it's selected).
The concept goes something like this:
- have all the available tags shown in a bar with the tags that apply
  for the selected client highlighted
- set up easy shortcuts for toggling Nth tag ie Ctrl+Alt+0..9 and maybe
even +q,w,e,r..p if you need more - irssi style
- have another shortcut for adding a new tag using the wmiimenu. The
items for the menu would be taken from a file that contains your most
used tags (user defined) and the tags that were used in the current
wmii session but are not used for any client atm
maybe some additional shortcuts for special things like: clear all
tags, apply all tags, floating related stuff etc

I believe this would be a better solution then the current way (which
is pretty cumbersome imo) because you don't need to retype everything
when working with multiple tags.

Because English is not my native language i wrote a small script that
demonstrates part of the concept (I'm also pretty new to shell
scripting so try to ignore any stupid things you see :) :

-x---------------- begin retag.sh ---------------------

#!/bin/bash

#----------------------------------- colors ----------------------------------#
black='\E[30;47m'
red='\E[31;47m'
green='\E[32;47m'
yellow='\E[33;47m'
blue='\E[34;47m'
magenta='\E[35;47m'
cyan='\E[36;47m'
white='\E[37;47m'

#-------- from : http://www.faqs.org/docs/abs/HTML/colorizing.html -----------#
###
cecho () # Color-echo.
                              # Argument $1 = message
                              # Argument $2 = color
 {
         local default_msg="No message passed."
                                      # Doesn't really need to be a local variable.
         
         message=${1:-$default_msg} # Defaults to default message.
         color=${2:-$black} # Defaults to black, if not specified.

           echo -en "$color"
           echo -n "$message"
           tput sgr0
         
           return
}
#------------------------------------------------------------------------------#

tags=` wmiir read /tags` #list of tags
nl=`wmiir read /tags | awk 'END { print NR }'` #number of tags

########## populate tagar ##################
i=1
for ctag in $tags
do
        tagar[$i]=$ctag
        #echo -n " $i.$ctag "
        i=`expr $i + 1`
done

####### get tags for selected client #######
seltags=`wmiir read /view/sel/sel/tags | sed -e "s/+/ /g"`

###### populate choicear ###################
for cseltag in $seltags
do
        #echo $cseltag
        for i in `seq 1 $nl`
        do
                if [ "$cseltag" = "${tagar[$i]}" ]; then
                        choicear[$i]=1
                fi
                
        done
done
while (true) do
        clear
        for i in `seq 1 $nl`;
        do
                if [ "${choicear[$i]}" = "1" ]; then
                
                  # echo -ne $red"$i.[${tagar[$i]}] "'\033[0m'
                    cecho "$i.[${tagar[$i]}] " $red
                else
                     # echo -n "$i. ${tagar[$i]} "
                      cecho "$i. ${tagar[$i]} " $blue
                fi
                #tput sgr0
        done
        echo; echo
        cecho "########## KEYS ############" $black; echo
        cecho "# 1..9 toggle tag #" $black; echo
# cecho "# x exit without saving #" $black; echo
        cecho "# q save and exit #" $black; echo
        cecho "############################" $black; echo
        read -s -n1 ch
        case "$ch" in
        [1-9])
                if [ "${choicear[$ch]}" = "1" ]; then
                        choicear[$ch]=0
                else
                        choicear[$ch]=1
                fi;;
        x)
                clear;exit;;
        q)
                #construct tags string
                for i in `seq 1 $nl`
                do
                        if [ "${choicear[$i]}" = "1" ]; then
                                if [ "$new_tags" = "" ]; then
                                        new_tags=${tagar[$i]}
                                   else
                                        new_tags=$new_tags+${tagar[$i]}
                                fi
                        fi
                done
                echo -n "The new tags for the selected client would be: "
                echo $new_tags
                
                exit;;
        esac
done
------------------ end retag.sh --------------------x-

When unique ids for clients will be available in wmii-4 these kind of
things could be done without wmii components.

I'm sure there can be better examples to justify this event than the
ones I presented.

Regards,
Neptun

----
<<Brescan Florin>> <<Neptun>> <<www.flo.haos.ro>>

Received on Mon Apr 24 2006 - 20:14:20 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:03:24 UTC