[wmii] wmiirc snippet: tag comments

From: Boo_boo <kaitarou_AT_gmail.com>
Date: Sun, 16 Sep 2007 19:03:17 +0400

generally i use numeric tagnames in wmii, because it's easier and faster to tag with and to navigate between views.
but numbers are'nt of any information about what is that tag for.
so i scripted wmii to support "tag comments"; the comment is some string, which may be assotiated with tag, and will be shown in tagbar/tagmenu after the tag name. maybe someone will find that feature useful too.

paste these lines somewhere near tagging rules:
#------
#predefined tag comments (example)
TAG_COMMENTS=$(cat<<!
1 -> www
3 -> dev
4 -> icq
!
)

#string to delimit tag name and tag comment in tagbar/tagmenu
TAG_CDELIM="-"

#outputs tag name with optional comment
tag_display() {
        echo -n $1`echo "$TAG_COMMENTS" | sed -n 's|^'$1'\s->\s\(.*\)$|'$TAG_CDELIM'\1|p'`
}
#------

paste these to keys definition block:
#------
        #set comment for current view tag ('d' for 'describe')
        Key $MODKEY-Shift-d
                tag_choosen=`wmiir read /tag/sel/ctl`
                new_comment=$(echo | $WMII_MENU)
                TAG_COMMENTS=`echo "$TAG_COMMENTS" | sed '/^'$tag_choosen'\s->\s/d'`
                if [ -n "$new_comment" ]
                then
                        TAG_COMMENTS=$TAG_COMMENTS$'\n'"$tag_choosen -> $new_comment"
                fi
                wmiir xwrite "/lbar/$tag_choosen" "$WMII_FOCUSCOLORS" "$(tag_display "$tag_choosen")"
#------

replase tagsmenu() function with:
#------
tagsmenu() {
        all_tags=`wmiir ls /tag | sed 's|/||; /^sel$/d'`
        for tag in $all_tags
        do
                menu_tags="$menu_tags"$(tag_display "$tag")$'\n'
        done
        choice=`echo -n "$menu_tags" | $WMII_MENU`
        for tag in $all_tags
        do
                if [ "$choice" = "$(tag_display "$tag")" ]
                then
                        echo -n "$tag"
                        return 0
                fi
        done
        echo "$choice"
}
#------

and, finally, replace tag name in all wmiirc tag names display code with "$(tag_display $tag_name)"
#------
        Event CreateTag
                echo "$WMII_NORMCOLORS" "$(tag_display "$@")" | wmiir create "/lbar/$@"
#------

#------
        Event FocusTag
                wmiir xwrite "/lbar/$@" "$WMII_FOCUSCOLORS" "$(tag_display "$@")"
        Event UnfocusTag
                wmiir xwrite "/lbar/$@" "$WMII_NORMCOLORS" "$(tag_display "$@")"
        Event UrgentTag
                shift
                wmiir xwrite "/lbar/$@" "*""$(tag_display "$@")"
        Event NotUrgentTag
                shift
                wmiir xwrite "/lbar/$@" "$(tag_display "$@")"
#------

#------
# Setup Tag Bar
seltag="$(wmiir read /tag/sel/ctl 2>/dev/null)"
wmiir ls /lbar |
while read bar; do
        wmiir remove "/lbar/$bar"
done
wmiir ls /tag | sed -e 's|/||; /^sel$/d' |
while read tag; do
        if [ "X$tag" = "X$seltag" ]; then
                echo "$WMII_FOCUSCOLORS" "$(tag_display "$tag")" | wmiir create "/lbar/$tag"
        else
                echo "$WMII_NORMCOLORS" "$(tag_display "$tag")" | wmiir create "/lbar/$tag"
        fi
done
#------

-- 
With best regards,
Boo-boo
mailto: kaitarou(^at^)gmail.com
Received on Sun Sep 16 2007 - 16:54:05 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:27:40 UTC