Hi,

The tagging example from the code snippets didn't worked for me so
I've created one for myself, attached.

It's spawns lot of processes, but does the job.

this is the worst line
echo $news | tr "+" "\n" | sort|uniq|tr "\n" "+"|sed "s/^\(.*\)+$/\1/g"

-- 
Can Burak Cilingir
-+-\n--+\n+++

As soon as we started programming, we found out to our surprise that
it wasn't as easy to get programs right as we had thought. Debugging
had to be discovered. I can remember the exact instant when I
realized that a large part of my life from then on was going to be
spent in finding mistakes in my own programs.

- M. Wilkes
xwrite() {
    file="$1"; shift
    echo -n "$@" | wmiir write "$file"
}

xwt() {
    xwrite /view/sel/sel/tags $1
}

get_tags() {
    wmiir read /view/sel/sel/tags
}

get_all_tags() {
    wmiir read /tags
}

add_or_remove_tags() {
        params=`echo $@ | tr "+" " "`
        for param in $params; do
                add_or_remove_tag $param;
        done
}

add_or_remove_tag() {
    tags=`get_tags|tr "+" "\n"`
    echo -e "$tags" | grep -q "^$1"
    result=$?
    if [ $result == 1 ]; then
        add_tag $1;
    else
        remove_tag $1;
    fi

}

add_tag() {
    olds=`get_tags`
    news=$olds+$1
    news=`echo $news | tr "+" "\n" | sort|uniq|tr "\n" "+"|sed 
"s/^\(.*\)+$/\1/g"`
    xwt $news;
}

remove_tag() {
    olds=`get_tags | tr "+" "\n"`
    news=`echo -e "$olds" | egrep -v "^$1\$" | sort |uniq|tr "\n" "+"|sed 
"s/^\(.*\)+$/\1/g"`
    xwt $news
}

tag_by_menu() {
    add_or_remove_tags `get_all_tags  | wmiimenu`
}

tag_by_menu

#parse_input(){
#    char=`echo $1|cut -c 1`
#    nonone=`echo $1|cut -c 2-`
#
#    case "$char" in
#       +)
#           echo "add_tag $nonone" 
#           ;;
#       -)
#           echo "remove_tag $nonone" 
#           ;;
#       *)
#           echo "add_tag $1"
#           ;;
#    esac
#
#}

Attachment: signature.asc
Description: Digital signature

_______________________________________________
[email protected] mailing list
http://wmii.de/cgi-bin/mailman/listinfo/wmii

Reply via email to