Wednesday, March 21, 2007

Spicing up your e-mail signature for fun and... well... fun!

Recently I got tired of my e-mail signature always looking the same. It bored me but I'm a bit too lazy to be changing it myself very often. So I figured out a way to spice it up a little and make it update itself automatically.

The tools I used for this tiny little project was the neat little application fortune and cron.

If you're using any sort of real operating system you already have cron installed. Chances are that you have fortune as well, but if you don't it shouldn't be very hard to find from some repository or other download source. If you are, like me, a Fedora Core user you will find it in the extras repository.

What fortune does is that it outputs a random quote taken from an installed database of quotes. There are plenty of funny and interesting quotes available for inclusion in this database, such as quotes taken from movies, books and TV-shows.

So I simply wrote a bash-script that takes a base signature, which in my case contains some contact information and the URL to my GnuPG public key, adds this to the output from fortune and stores it all in a simple text file. The resulting file is what I then tell my e-mail client to use for a signature.

The script looks like this:

#!/bin/bash
SIGN_DIR=/home/hayabusa/documents
rm -f $SIGN_FILE/mailsignature
cat $SIGN_DIR/basesignature > $SIGN_DIR/mailsignature
fortune >> $SIGN_DIR/mailsignature
exit 0

So as you can see, nothing fancy at all.


Then to make the signature change once every fifteen minutes I added this row to my /etc/crontab:

*/15 * * * * hayabusa /home/hayabusa/bin/mailsign_maker.sh >/dev/null

Now let's see for how long this keeps me "not bored" with my e-mail signature ;-)

Oh, and by the way, I realize I am far from the first that's done something like this. I just figured I might not be the last wanting to do it either.

1 comment:

Anonymous said...

Cool idea. I do something similar with fortune and my banner statements and MOTD.