Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
check if I got mail
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
legokloss
n00b
n00b


Joined: 20 May 2003
Posts: 14
Location: Hamar, Norway

PostPosted: Thu Apr 29, 2004 7:05 am    Post subject: check if I got mail Reply with quote

I got a led on my laptop I can get to blink if I want to and want it to blink when I got new mail. Does anyone know if there is a deamon (really a deamon, running from a init-script for example, not demping on X) in portage (and if not, could tell me where I can find something to compile myself) who can check if there is mail in my local maildir/mbox and run a given command?

Have looked through net-mail/ and the searched the forum but havn't found anything that looks like something like this.

Thanks in advance!
_________________
Martin Holt Juliussen
Sleep, she is for the weak


Last edited by legokloss on Fri Apr 30, 2004 12:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
UncleTom
Apprentice
Apprentice


Joined: 20 Aug 2003
Posts: 194
Location: Bern, Switzerland

PostPosted: Thu Apr 29, 2004 1:52 pm    Post subject: Reply with quote

I have no idea about such a demon, but you could probably write a small bash script that checks the contents of .maildir/new and starts blinking the led if there is new mail. When there is no more new mail it stops the blinking.

You could then run that script from cron every minute or so.
_________________
bug, n: A son of a glitch.
Back to top
View user's profile Send private message
legokloss
n00b
n00b


Joined: 20 May 2003
Posts: 14
Location: Hamar, Norway

PostPosted: Thu Apr 29, 2004 11:49 pm    Post subject: Reply with quote

UncleTom wrote:
I have no idea about such a demon, but you could probably write a small bash script that checks the contents of .maildir/new and starts blinking the led if there is new mail. When there is no more new mail it stops the blinking.

You could then run that script from cron every minute or so.

Yeah, of course. Seems obvious now. Cron doing the deamon job. Thanks.
_________________
Martin Holt Juliussen
Sleep, she is for the weak
Back to top
View user's profile Send private message
UncleTom
Apprentice
Apprentice


Joined: 20 Aug 2003
Posts: 194
Location: Bern, Switzerland

PostPosted: Fri Apr 30, 2004 6:52 am    Post subject: Reply with quote

legokloss wrote:

Yeah, of course. Seems obvious now. Cron doing the deamon job. Thanks.

You're welcome.

BTW, how do you control the led?
_________________
bug, n: A son of a glitch.
Back to top
View user's profile Send private message
legokloss
n00b
n00b


Joined: 20 May 2003
Posts: 14
Location: Hamar, Norway

PostPosted: Fri Apr 30, 2004 12:02 pm    Post subject: Reply with quote

UncleTom wrote:
BTW, how do you control the led?

I have a Acer TravelMate 620 who got some shortcut buttons and a mail led. It has been made a couple of kernel modules for the travelmate (#1,#2) that use the input system in the kernels to add support for the buttons and adds support for the led. To get the led blinking (there is only to states: off and blinking) you can with the acerhk driver do as follows:
Code:
# echo on > /proc/driver/acerhk/led


#1: http://www.informatik.hu-berlin.de/~tauber/acerhk/
#2: http://www.math.columbia.edu/~jensen/linux/acertm/
_________________
Martin Holt Juliussen
Sleep, she is for the weak
Back to top
View user's profile Send private message
Celtis
l33t
l33t


Joined: 05 Jul 2003
Posts: 737

PostPosted: Fri Apr 30, 2004 12:04 pm    Post subject: Reply with quote

Just purely out of interest, how are you going to stop it blinking? Either have the cron daemon time out or are you going to manually reset the LED?
Back to top
View user's profile Send private message
legokloss
n00b
n00b


Joined: 20 May 2003
Posts: 14
Location: Hamar, Norway

PostPosted: Fri Apr 30, 2004 12:25 pm    Post subject: Reply with quote

BTW, I found a script to do the job (from one who needed to do the same thing) when I searched for information about how to get the module working.
This should also answer Celtis question:
Celtis wrote:
Just purely out of interest, how are you going to stop it blinking? Either have the cron daemon time out or are you going to manually reset the LED?


This one check if there is new mail in .maildir/new:
Code:
#!/bin/sh
if [ -z "$UHOME" ]; then
  UHOME=$HOME
fi
MAILDIR=$UHOME/.maildir
MAIL=`ls -A $MAILDIR/new/`
if [ -z "$MAIL" ]; then
 exit 0
fi
exit 1


And this one use the other scripts and lights the led if there is new mail and turns it off if .maildir/new is empty:
Code:
#!/bin/sh
DEV=/proc/driver/acerhk/led
[ -f $DEV ] || exit 0
USER="$(who | awk '/./ { if ( $2 == ":0" ) print $1 }')"
if [ ! -z "$USER" ]; then
  LED="off"
  UHOME="/home/$USER" /usr/local/bin/maildir-new
  if [ "$?" == "1" ]; then
    LED="on"
  fi
  echo $LED > $DEV
fi


The guy(could actually not find his name on his personal site;-) who made this script also got a nice tutorial for installing gentoo on TravelMate 630:
http://www.odi.ch/prog/tm630/index.php
All credit goes to him
_________________
Martin Holt Juliussen
Sleep, she is for the weak


Last edited by legokloss on Fri Apr 30, 2004 12:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
UncleTom
Apprentice
Apprentice


Joined: 20 Aug 2003
Posts: 194
Location: Bern, Switzerland

PostPosted: Fri Apr 30, 2004 12:34 pm    Post subject: Reply with quote

Cool, I must go and have a look at my vaio to see if it's got anything like that too. :D

Thanks for posting the scripts and the links.

Celtis wrote:
Just purely out of interest, how are you going to stop it blinking? Either have the cron daemon time out or are you going to manually reset the LED?

The cron job turns the led on or off, depending on what it finds in the maildir.
_________________
bug, n: A son of a glitch.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum