Re: [wmii] Mail notification

From: Kris Maglione <bsdaemon_AT_comcast.net>
Date: Wed, 20 Jun 2007 12:29:58 -0400

On Wed, Jun 20, 2007 at 02:50:58PM +0100, Adam Gray wrote:
> I want to implement some kind of mail notifier next to the clock in
> the Wmii bar.

This is my current mail notifier:

http://www.suckless.org/wiki/wmii/scripts/mail_notifier

My old one:

#!/usr/bin/env -S PATH=${PLAN9}/bin:${PATH} rc

#How often to check
delay=5
#Your Maildir folders
mailboxes=$home/Maildir/^('' .wmii .9fans)
#Do you want to know the count?
showcount=0

pidfile=$home/.wmii-3.5/mailcheck

oldpid=`{cat $pidfile >[2]/dev/null}
{ /bin/kill $oldpid >[2]/dev/null
   sleep 2
   /bin/kill -9 $oldpid >[2]/dev/null }&
echo -n $pid > $pidfile

# Note, I use the name xmail so the bar is placed after status
wmiir remove /bar/xmail >[2]/dev/null
sleep 2

fn sigexit {
        wmiir remove /bar/xmail 2>/dev/null
        if(~ `{cat $pidfile >[2]/dev/null} $pid)
                rm $pidfile
}

flasher_pid=0

fn flash {
        while (wmiir read /def/selcolors | wmiir write /bar/xmail/colors
                && sleep 1
                && wmiir read /def/normcolors | wmiir write /bar/xmail/colors)
                sleep 1
}

while() {
        mailcount=`{{ for(i in $mailboxes)
                        ls $i/new } | wc -l}
        if(! ~ $mailcount 0) {
                wmiir create /bar/xmail
                if(! ~ $showcount 0)
                        echo -n Mail $mailcount | wmiir write /bar/xmail/data
                if not
                        echo -n Mail | wmiir write /bar/xmail/data
                
                if(~ $flasher_pid 0) {
                        flash &
                        flasher_pid=$apid
                }
        };if not
        if(! ~ $flasher_pid 0) {
                wmiir remove /bar/xmail
                kill $flasher_pid
                flasher_pid=0
        }
        
        sleep $delay
}

-- 
Kris Maglione
Any given program, when running, is obsolete.

Received on Wed Jun 20 2007 - 18:30:37 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 16:25:12 UTC