Using sieve to filter and organise your mail on arrival

2009-07-31 – 08:00 by Thijs Braem
This is a sieve (also known as a strainer).
Image via Wikipedia

In Thomas A. Limoncelli’s “Time Management for System Administrators” there’s a chapter about how to manage e-mail. When, a couple of years ago, I first read the book, I implemented some of the tips by using simple Thunderbird filters, but after re-reading now I found room for improvement. The improvement is called: “sieve”. Using these filters I now created in Sieve, I can have the benefits of an empty inbox without having too much of a risk of loosing important e-mails that are needed afterwards (yes, Mr. Limoncelli, sometimes I do need old e-mails as reference or “proof”). So how to get this done?

Doing it in Thunderbird

First: how I did it before. Thunderbird allows for creating filters through the “Tools”>”Message filters” menu. Those are executed on arrival of the messages in the e-mail software, and I had lots of them:

  • e-mails from specific mailing lists would go to specific folders I created for those mails. The filters were (and are still) very simple: “Match any of the following” would include from-adresses or “to or cc”-conditions, and “perform these actions” would only consist of “move message to” the specific folder I created for the list. Later I added, for the mailing lists that I sometimes read, but shouldn’t disturb me from my work, the “Mark as read” action. That way I wouldn’t see the “new messages” icon for those that I shouldn’t necessarily read.
  • e-mails from certain monitoring systems would also go in specific IMAP folders, usually it “is” important to have these disturb me (they would for instance be Nagios messages indicating that a certain service just went down) so no “Mark as read” there.
  • recently i added another one, that would allow me to have an empty inbox. I call it the “Auto Archive” filter and it simply consists of checking the date and if the message is from a certain year, then copy it to the archive folder of that year and then mark it as read (this results in the copy being marked as read, and the original staying unread). This way you can always delete any message from the inbox after processing and know that it still exists in the archive.

The only, but still pretty irritating, problem with this is that it would require all your Thunderbird installations to have those filters in place. This is where Sieve jumps to the rescue, it will filter the mails on arrival on the IMAP server. I’m not quite sure how much mail servers support Sieve by default, but I think it’s quite widespread. Using it is actually pretty self-explanatory, and you will find some websites with good explanations and examples as well.

Managing the scripts

There are generally two ways you can upload your scripts: do it the “sieveshell” command-like way, or use the Thunderbird Sieve plugin.

For sieveshell I installed sieve-connect and cyrus-admin-2.2 as packages in Ubuntu, although I guess only one of those is the one you need, I’m too lazy to find out now. Usage is very easy:
thijs@pingu:~$ sieveshell --authname=thijs imap.server.be
connecting to imap.server.be
Please enter your password:
> help
Usage:
sieveshell [-u username] [-a authname] [-r realm]

help - this screen
list - list scripts on server
put []
- upload script to server
get []
- get script. if no filename display to stdout
delete - delete script.
activate
- set a script as the active script
deactivate - deactivate all scripts
quit - quit
>

As you can see you can get a list of existing scripts, get one, change it, then put it up there again and activate it.

Or you could also install the Thunderbird Sieve extension. Install it in Thunderbird, enable Sieve for an account using “Tools”>”Sieve Filter Settings”, setting the right properties (you might have to disable TLS, and maybe your server only allows for “plain” authentication – booh!), and you can go on and add your filter in “Tools”>”Sieve Message Filters”.

Making the scripts

All the filters I spoke of before, were translated into Sieve script. Most of it went smoothly, I just had to look some more into the “copying but leaving the original there” bit, but in the end this also worked out very well. I just paste part of the script as reference, read the comments for more explanations.

#
# 2009-7-29
#
# first make sure you "require" certain modules on the IMAP server:
require ["fileinto", "reject", "imapflags"];

# simple moving to another folder if the sender is a specific address
if header :contains ["From"] "otrs@myserver.be" {
  fileinto "OTRS"; # This is an existing folder on the IMAP server, in a lot of cases this will be something like "Inbox.OTRS", but on my specific server it isn't
  stop;
}

# now continue all the rest with "elsif", I lost some time over looking for an error when I had typed "elseif" (with an extra e) as it is in most languages
elsif header :contains ["From"] "nagios@myserver.be" {
  fileinto "Nagios Notifications";
  stop;
}

# this is also just moving to another folder, but this sort of mail shouldn't bother me so there's a little extra...
elsif header :contains ["From"]
  ["root@myserver.be","root@myotherserver.be"] {
  addflag "\\Seen"; # this makes sure that the message is marked as "read"
  fileinto "System-administration";
  stop;
}

# in this one the "from" as well as the "to" and the "cc" headers can contain any of the e-mail adresses listed
elsif  header :contains ["From", "To", "cc"]
    ["debian-security@lists.debian.org","debian-security-announce@lists.debian.org"]{
  fileinto "Mailing lists/Debian-security(-announce)";
  stop;
}

# a simpler one, message that shouldn't disturb me
elsif header :contains ["to","cc"] "mailman-users@python.org"
{
 addflag "\\Seen"; # there are more cool IMAP flags where this came from!
 fileinto "Mailing lists/Mailman-Users";
 stop;
}

# the "anyof" function serves as a sort of "or"
elsif anyof (
    header :contains ["Subject"] "[Security announcements]",
    header :contains ["From"] "noreply@drupal.org",
    header :contains ["to","cc"] "support@drupal.org" )
{
  addflag "\\Seen";
  fileinto "Mailing lists/Drupal";
  stop;
}

# have mailman moderation messages moved to their specific folder, you can see that the e-mail addresses are not necessarily complete (if you want that, use the :is operator)
elsif header :contains ["to","cc"]
  ["-owner@myserver.be","mailman-bounces@myserver.be"]
{
 fileinto "Mailman moderation";
 stop;
}

# and this is my favourite rule, keeping the "delete" message safe in the inbox!
else {
  # ARCHIVE THE MESSAGE BUT LEAVE IT IN INBOX
  addflag "\\Seen";
  fileinto "ARCHIVES/2009"; # copy a "read" message to the archives folder
  removeflag "\\Seen"; # but make the one we keep unread
  keep; # this results in a copy both in archives and inbox
  stop;
}

That’s it! Just upload your filters to the server, activate it and off you go! There are of course a lot more possibilities I don’t use, or need, but you’ll figure those out by yourself of course :p

Reblog this post [with Zemanta]

Video van deredactie.be in DVD-speler-speelbaar formaat omzetten met Ubuntu Linux

2009-03-11 – 21:17 by Thijs Braem
FFmpeg
Image via Wikipedia

Dit is nog zo’n kleine “misschien heb ik -of iemand anders- dit nog ooit nodig, dan moet ik -of iemand anders- het niet meer opzoeken”-howto, ditmaal in het Nederlands omdat het weinig zinvol lijkt om het in het Engels te doen.

Hoe aan het originele videobestand raken?

* Zoek de juiste video hier (als dit lukt: ga verder naar “Omzetten naar mpeg2“) of open de pagina op http://www.deredactie.be waarop het stukje video staat.
* Bekijk de broncode van die pagina (in Firefox: rechtsklikken op een lege plaats op de pagina en kiezen voor “broncode bekijken”)
* Zoek naar de tekst “div_flash” (waarschijnlijk lukt “.flv” ook). Die tekst zal voorkomen in de buurt van een lijn die eruitziet als deze:
variablesArray.append(new Array('v_videoUrl','http://media.vrtnieuws.net/2009/03/191019565ONL0903111956725_urlFLVLong.flv'));
* Kopieer de URL daaruit en open een terminal.
* Geef het volgende commando in om de bruikbare video te downloaden:
wget http://media.vrtnieuws.net/2009/03/191019565ONL0903111956725_h263hi.mp4
(let erop dat dit dezelfde URL is, maar het deel na “_” is vervangen door “h263hi.mp4″)

Omzetten naar mpeg2

Dit omzetten gaat het makkelijkst met ffmpeg (”sudo aptitude install ffmpeg”).

In de terminal, geef het volgende commando in:
ffmpeg -i videobestand.mp4 videobestand.mpeg

That’s it!

Reblog this post [with Zemanta]

About democracy and responsibility

2009-02-10 – 21:36 by Thijs Braem
Gaza Beach
Image via Wikipedia

Seeing the news about the Israeli elections today made me realise that maybe ‘responsibility’ is the missing ingredient of democracy. Yes, politicians will in some cases be found responsible for their acts in decent working democracies, but the voter will never have to stand for the damage his choice does to other people.

We got to see video footage of Israeli right wing voters saying things like ‘death to Arabs’, CNN speaks of ‘a popular war’ when talking about the recent war in Gaza, we see people sipping from their drinks on the beach while explaining to the camera why they will vote for Avigdor Lieberman (of whom they know damn well he will cause death and destruction in the Palestinian Territories when given power), etc. A couple of years ago the same thing happened in the US of A: people voted the candidate they knew was going to continue waging war to stay in office, resulting in thousands of deaths and millions of broken families. Nobody of those voters will ever have to pay for the crimes they permitted to commit.

In reality this responsability of the voters would probably be very difficult to accomplish, for one because who you vote for is usually secret, but I do believe it should at the very least be something people think about before casting that vote. One can only hope, of course…

Reblog this post [with Zemanta]

Vegetarisch stoofpotje

2009-01-27 – 23:16 by Thijs Braem
Three semi-random paprika fruits found in Joy'...
Image via Wikipedia

Recept voor vegetarisch stoofvlees voor ongeveer 2 personen. Het recept is verbazingwekkend simpel, al moet je wel geduld hebben.

Ingrediënten
Tofu of seitan (250g)
2 flesjes geuzebier (of bruin bier)
1 ajuin
een halve rode paprika
1 wortel
Peper
Zout
Mosterd
Een oude boterham
2 laurierblaadjes
2 kruidnagels
2 eetlepels thijm
1 eetlepel bruine suiker
1 blokje groentenbouillon
Boter

Laat boter smelten op een halfhoog vuurtje in een steelpan of pot die groot genoeg is voor alle ingrediënten en doe er de seitan (ik probeerde tofu: dat werkt ook maar valt uiteen) in vrij grote stukken (ongeveer zoals ze bij echt stoofvlees zijn). Kruid met peper en een klein beetje zout. Bak aan tot het een beetje kleur krijgt.
Zet het vuur lager en doe er de niet te fijngesneden ajuin bij en laat bakken totdat het glazig is.
Nu kunnen de flesjes bier erbij, samen met de laurier, de kruidnagels, de thijm, de paprika in stukken, de wortel in schijfjes en het bouillonblokje.
Laten pruttelen.
Eens het kookt kan je het vuur heel laag zetten en laten verder pruttelen. Bovenop kan je de boterham leggen waarop je een goeie laag mosterd hebt gesmeerd, je kan er ook eventueel een eetlepel bruine suiker bijdoen. Leg een deksel op de pot en laat een uur of 2-3 verderpruttelen, af en toe roeren mag (geen idee of het moet).
Nu is het éigenlijk klaar, maar het is extra lekker als je het een nacht laat staan en de volgende dag opeet. Op te dienen, natuurlijk, met frietjes, mayonnaise en appelmoes ofzo!

Reblog this post [with Zemanta]

Darkening Kubuntu 8.10 aka Intrepid Ibex

2009-01-22 – 23:28 by Thijs Braem
K Desktop Environment
Image via Wikipedia

Every once in a while I get it in my head to try a dark theme on my desktop computers. Sometimes I seem to think they look nice, which they of course don’t, they’re just depressing. Sometimes I pretend it’s better on the eyes (that’s my current excuse), and it’s less distracting then a lot of colours. And sometimes it’s just the last theme I tried when I was bored. Every time though I have to go find how to make everything “fit” so I don’t get stuck with black letters on a black background or things like that. So this is a small list of things to do to make several of the programs I use work.

KDE:
Click the KDE “start” button, choose “System Settings” . Click “Appearance” -> Colours. Here you can choose between several colour themes, I chose “Obsidian Coast”.

Kate:
In the menu choose “Settings” -> “Configure Kate”.
On the left click “Editor Component” -> “Fonts & Colours” -> “Colour tab”.
Click on the coloured bar behind “Text area background” -> “Normal text”, here you can choose for example “plain black”. I’ve also changed the “current line” background to “#1F1F1F” (which is very dark, but it will still be visible which is the current line). You can pick more colours in the “Normal Text Styles” tab.

Firefox / browsing:
Using KDE system colours (which is default, if I remember correctly), Firefox should already be quite OK by now. But if you want, you can install for instance the Firefox Pitchdark theme. This will make scrollbars etc. more visible, though I must say I’m not so fond of how the tabs look there. “NASA Night Launch” is the one I liked more.

When browsing, most of your screen will be occupied by the colours chosen by the people that made the sites you visit. Because this is usually black on light background, you might want to change that behaviour too. Just using the Firefox preferences to default to black background will in a lot of cases give you illegible pages. To solve this, you can use the Darken Greasemonkey user script; it’s a very simple user script that will make the background black and any text except links white. By default it will work for any (*) page you view, but you could add exceptions by right-clicking the greasy monkey in Firefox (usually on the bottom right), choosing “Manage user scripts”,select “Darken” and add addresses to the “Excluded pages” box.

Thunderbird:
In my favourite e-mail client I used the PitchDark theme.
To install it click “Tools” -> “Add-Ons” -> “Themes”, install the downloaded theme and click “Use Theme” to apply. This theme has the added advantage that it also supports the Lightning plug-in.

I’m not sure anymore this was really necessary anymore (I did this before installing the Pitchdark theme), but I also did:
“Edit” -> “Preferences” -> “Formatting” -> “Colours” -> (white text on black background)

Amarok:
Click “Settings” -> “Configure Amarok”.
Choose “Appearance” -> “Colour scheme” -> “Custom color scheme”, choose black background.
Context browser style: “example”.

Okular:
Click “Settings” -> “Configure Okular”.
“Accessibility” -> “Change Colours” -> “Colour mode” “Invert Colours”.
While you’re at it: there’s also the option to not “Obey DRM limitations” in the “General” menu here!

oOo:
For OpenOffice.org I don’t have a good solution yet, but I for one don’t use it all that often. Anyone who does know how to do this: feel free to add it to the comments!

[gallery link="file" columns="2"]
Reblog this post [with Zemanta]