I include Latin phrases in my e-mail signature at work. It’s a fun little thing I do just to make people interested.
So I decided to make a signature that would include a random Latin phrase in every e-mail I send. Thankfully, Evolution makes this easy.
First, I make a text file which I call sigquotes.txt , and stash it in my home directory, under a folder for personal items. I put one quote per line.
Next, I have to write a little ditty to grab a random line from that file and output the results. I used PHP for this, but almost anything could have worked. I dump the following into sigrand.php :
<?
$quoteFile = "/home/icanhaslinux/personal/sigquotes.txt";
$fp = fopen($quoteFile, "r");
$content = fread($fp, filesize($quoteFile));
$quotes = explode("\n",$content);
fclose($fp);
srand((double)microtime()*1000000);
$index = (rand(1, sizeof($quotes)) - 1);
echo "________<br>LightningCrash<br>Resident Unix Witchdoctor<br><br>";
echo $quotes[$index] . "<br>";
?>
Easy enough. I had problems getting the php itself to run as a script, so I had to make another short script to launch the PHP file. I put the following into sigrand.sh :
/usr/bin/php5-cgi -q /home/icanhaslinux/personal/sigrand.php
I chmod +x sigrand.sh and go on my way to the next step.
I fire up Evolution, go to Edit->Preferences. I go to Composer Preferences and click on Signatures. Then I click on the “Add Script” button, name it Random Latin, navigate to /home/icanhaslinux/personal, and select sigrand.sh as my signature script.
That part is done. Now to make it default for my outgoing e-mail. From the Preferences page, I click edit on my e-mail account. On this page, I have a drop-down box where I can select my signature for this account. I select Random Latin, of course. I then click OK and Close.
Now, to test it out, just fire up a new e-mail.
Until next time!
-LightningCrash
EDIT: It’s been requested that I make clear what license this code is issued under. I consider the code snippets on this article to be public domain and not subject to licensing. Use the code in this article as you see fit.
This is very nice, thanks – found it useful!
I think PHP-CGI is not as common on desktops as Python; also, I’m learning Python and this was an easy exercise – so I converted your code to Python, in response to a query on my home LUG (Goa, India), and posted it there (see http://tech.groups.yahoo.com/group/ilug-goa/message/18028 if interested) (the archives are publicly accessible, no need to sign up).
Another member asked about copyright/license information, and though my post to the LUG attributed your blogpost as the source, it would be nice if you would clarify the license for your PHP-CGI code, which my Python conversion is very obviously derived from
so I can license the limited rights I have on the converted code. Would you please consider mentioning a FOSS license for your code, in an update to your blogpost?
Thanks in advance,
Ed.
Sorry it took me a while to get back to you on this. Most of my comments are spam, so I tend to ignore them.
Being that this is just a snippet of code, I’ll declare the code itself to be public domain.