Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to let fetchmail play a sound when it's done fetching emails?

share|improve this question
up vote 0 down vote accepted

If you have ffmpeg installed, you can use it to play a sound of almost any filetype:

ffplay -nodisp /path/to/sound/file

Unfortunately that will spawn a window in most versions of ffmpeg included with Linux distributions, though it has been fixed in the latest version. If that's undesirable, you can also use the aplay command, but that can only play WAV, AU and other raw audio formats:

aplay /path/to/sound.wav

If you don't want to have to type that every time, you can write a little script to do it for you. Just drop a file like this to somewhere like ~/bin/fetchsound and make it excuatable (chmod +x ~/bin/fetchsound):


fetchmail [..]

if [ $? -le 1 ]; then
    ffplay -nodisp /path/to/sounds/success.ogg
    ffplay -nodisp /path/to/sounds/failure.ogg

You could also just have it play a sound when you have new mail, because fetchmail returns a 0 exit code when it downloads new mail and 1 when it doesn't. (All other status codes indicate a failure.)


fetchmail [..]

if [ $? -eq 0 ]; then
    ffplay -nodisp /path/to/sounds/newmail.ogg
elif [ $? -gt 1 ]; then
    ffplay -nodisp /path/to/sounds/failure.ogg
share|improve this answer
The problem is I run fetchmail in daemon mode like fetchmail --keep --verbose --ssl --fetchlimit 0 --fetchsizelimit 0 --timeout 45 --daemon 180 --fetchmailrc ${HOME}/.fetchmailrc-pop Will your solution work after each 180 second interval? – Computist Apr 5 '11 at 17:33

If you're running it in the foreground:

fetchmail ...; printf '\a'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.