Re: [dwm] Notifications

From: Carlos Pita <carlosjosepita_AT_gmail.com>
Date: Mon, 29 Sep 2008 21:18:05 -0300

> I've wrote a simple bash script that takes care of wrapping long lines

I think I should have given an example of its intended usage:

notify "Martin says:" "I'm going home now, I will give you a call later, cyl!"

The second parameter will be wrapped. The popup will appear
uncollapsed (both title and body lines visible), top-left and stay for
8 seconds. These are the defaults, which can be easily changed by
tweaking the code.

Regards
-Carlos

> #!/bin/sh
>
> FONT=-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*
> WIDTH=40
> COLORS="-bg black -fg red"
> SCREEN_WIDTH=1280
> TIMEOUT=8
>
> if [[ -z $1 ]]
> then
> echo "Usage: notify title_line [other_line...]"
> exit 1
> fi
>
> pkill dzen2 # kill previous notification
> text=$1
> if [[ -n $2 ]]
> then
> body=`echo $2 | fold -s -w $WIDTH`
> text="$text
> $body"
> fi
> lm=(`echo "$text" | awk -v font=$FONT 'BEGIN { max = 0; } {
> ("textwidth " font " \"" $0 "\"") | getline cur; if (cur > max) { max
> = cur } } END { print (NR-1) " " (max+20) }'`)
> if ((lm[0] > 0))
> then
> larg="-l ${lm[0]}"
> fi
> warg="-w ${lm[1]}"
> xarg="-x $((SCREEN_WIDTH - lm[1]))"
> echo "$text" | dzen2 -p $TIMEOUT $xarg -y 0 $warg $larg -bg black -fg
> red -fn $FONT -e "onstart=uncollapse;button3=exit"&
>
> exit 0
>
>
> Regards
> -Carlos
>
Received on Tue Sep 30 2008 - 00:18:05 UTC

This archive was generated by hypermail 2.2.0 : Tue Sep 30 2008 - 00:24:04 UTC