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

0

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

Computist

Posted 2011-03-19T02:52:41.753

Reputation: 2 341

Answers

0

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):

#!/bin/bash

fetchmail [..]

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

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.)

#!/bin/bash

fetchmail [..]

if [ $? -eq 0 ]; then
    ffplay -nodisp /path/to/sounds/newmail.ogg
elif [ $? -gt 1 ]; then
    ffplay -nodisp /path/to/sounds/failure.ogg
fi

Patches

Posted 2011-03-19T02:52:41.753

Reputation: 14 078

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 – 2011-04-05T17:33:04.220

0

If you're running it in the foreground:

fetchmail ...; printf '\a'

Paused until further notice.

Posted 2011-03-19T02:52:41.753

Reputation: 86 075