Lutin's (sort of) blog
Automatically filter mails using List-Id with imapfilter -- Sun, 22 Nov 2009 12:07:48
Some time ago, I switched from a pop+fetchmail+procmail setup to using imap+imapfilter+offlineimap, which makes it way easier to sync mails from/to multiple computers. However, one thing I've missed a lot is the ability to do automatic filtering based on list-id with procmail, which is very convenient when you're subscribed to a lot of lists. Recently I found some old code snippets allowing that with imapfilter, and updated them to work with current versions of imapfilter.
First, you need a function that will parse the list-id header to extract the folder name. This one is pretty simple and might not work in some cases, but it appears to work on all the mailing lists I'm subscribed to.
function parseListId(header)
baseheader = string.sub(header, string.find(header, ':')+1, nil)
destname = ''
for i=1,string.len(baseheader) do
c = string.sub(baseheader, i, i)
if c == '<' then
-- reset destname on any < brackets
destname = ''
elseif c == '.' then
-- stop on the first .
return destname
elseif c ~= ' ' then
-- add any non-space character to the destination name
destname = destname .. c
end
end
end
And then, you need to actually fetch the list-id headers and sort your e-mails accordingly
results = GMAIL['INBOX']:match_field('List-Id', '.*<.*>')
listids = GMAIL['INBOX']:fetch_fields({'List-Id'}, results) or {}
mailboxes = {}
for message, header in pairs(listids) do
mailbox = parseListId(header)
if not mailboxes[mailbox] then
mailboxes[mailbox] = {}
end
table.insert(mailboxes[mailbox], message)
end
for mailbox, messages in pairs(mailboxes) do
GMAIL['INBOX']:move_messages(GMAIL[mailbox], Set(messages))
end
That's it, imapfilter now filters your messages according to the List-Id field. Enjoy!
Sbuild list-missing hook -- Tue, 13 Jan 2009 15:30:08
Time for some random content, as it's been almost a year since I last put something uninteresting here. When I switched from pbuilder to sbuild to build debian packages, what I missed most is the little hook script I used to list missing files - files in debian/tmp that are not part of any package. As some google digging didn't work out so weel to find its sbuild-compatible equivalent, I've finally written a
hook script for schroot that does this.
A couple notes on it though:
- You need to set $purge_build_directory="never"; in your ~/.sbuilrc for this to work, or otherwise the build directory will get deleted, and the script won't work (this doesn't matter much if you're using lvm snapshots, however that might end up eating up a lot of space if you're using the file-based method)
- You need to put it in /etc/schroot/setup.d, and as it runs fakeroot and uses cdbs' utils.mk file, you'll need both of those packages installed.
Well, that's pretty much it. You weren't expecting some real content, were you?
Enlightened Boot -- Fri, 15 Feb 2008 07:45
Some time ago,
Rasterman wrote Exquisite, a pretty neat EFL-based, drop-in usplash replacement. After some efforts, I got it working at startup on my computer, and packaged it so that people can enjoy it painlessly.
However, many people don't use packages, and I've been asked several time to write a how-to make it work, so here it is :)
Thou Shalt Not Use The Framebuffer -- Sun, 11 Nov 2007 21:29
I know, I should have written something about the awesomeness of Gutsy. Should have...
...But while I didn't do it, there's a feature among the ton of cool things gutsy brought, that I'd want to share with you: The out-of-the-box non-working framebuffer
So, howto to enjoy that shiny new feature ?
- Edit /boot/grub/menu.lst with your favorite text editor and put vga= in your default boot options. Don't forget to save.
- Run 'sudo update-grub'.
- Reboot your computer.
And here is the best weapon to fight against the 'linux is all about command-line' opinion: You just can't use your console. Don't tell me you're not happy, I know you've been wanting to get rid of it for ages.
I have to say, it's been a pretty good collaboration between users and the kernel development team to bring this feature in:
A bug about that new function was filed 2 months before the release, set as critical (now, you see how badly users wanted their framebuffer not to work),
got dozens of answers and about 20 duplicates, and the kernel team did a great job at keeping this feature in gutsy.
Ok, let's stop the sarcasm. Actually they did answer. 'Just remove vga= from you kernel command line'.
Enjoy :)
PS: in case you would be interested in a solution, you might want to look at the
Launchpad Bug #129910.
echo 'Hello, World!' -- Fri, 12 Oct 2007 19:50
Hello, World!
Well, some people have been telling me for a while that I should have a blog....Let's try :)