Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Publicaciones sobre kde (publicaciones antiguas, página 24)

A KDE hack: Faster mail searches in kmail, using mairix

Kmail search­es slow­ly.

I have been a kmail us­er for a cou­ple of years, since I set­tled in my own home of­fice with my own com­put­er.

I like the thing.

How­ev­er, it an­noys me that it takes sooooo long to find a mes­sage in my mail­store. Hey, it's on­ly 13000 mes­sages!

So, while I wait for KDE4 to bring all its search­ing good­ness, I de­cid­ed to see if I could hack some­thing quick­ly.

En­ter mair­ix: a mail in­dex­er/search thing.

Con­vinc­ing mair­ix to in­dex all my mail was rather sim­ple (here is my ~/.­mair­ixr­c):

base=/home/ralsina/
maildir=Mail/*...
maildir=.kde/share/apps/kmail/dimap...
omit=Mail/mairix
database=~/.mairix_db

What does it do?

  • It in­­dex­es mail stored at ~/­­Mail and ev­ery­where in my kmail imap fold­er­s.

  • It stores search re­­sults in ~/­­Mail/­­mair­ix and ig­nores its con­­tents when search­ing. The re­­sults are stored as links, so they waste no disk space.

Af­ter run­ning mair­ix so it builds its DB (took about a min­ute, which is less than most kmail search­es) , you can search for things like this:

[ralsina@monty ~]$ time mairix b:bartleblog
Matched 6 messages

real    0m0.232s
user    0m0.012s
sys     0m0.204s

And the re­sult can be seen in kmail, in the mair­ix fold­er:

mairix1.png

How­ev­er, there is a prob­lem. It will work for the first search, but not for the sec­ond one. On the sec­ond search, you get the same con­tent list­ing, but all mes­sages ap­pear emp­ty.

That's be­cause kmail saves an in­dex file of each fold­er. To work around that, I wrote a lit­tle shell wrap­per, kmair­ix:

#!/bin/sh
rm ~/Mail/.mairix* -f
mairix $*

And you use that in­stead of call­ing mair­ix di­rect­ly.

But there are still im­prove­ments to be done. If your kmail is cur­rent­ly dis­play­ing the mair­ix fold­er, search­ing does­n't up­date the mes­sage list.

DCOP to the res­cue! We can switch to the in­box, then back to mair­ix (ad­just as need­ed for your­self):

dcop kmail KMailIface selectFolder /Local/inbox
dcop kmail KMailIface selectFolder /Local/mairix

Miss­ing pieces:

  • How about switch­ing to the kmail win­­dow? Sad­­ly, the kwin DCOP in­­ter­­face seems in­­­com­­plete. Maybe as­sign­ing kmail a hotkey and work from there? Let me know if you have any ideas.

    UP­­­DATE as sug­­gest­ed by An­no He­im­burg: just call kmail.

  • A GUI (of course!) prob­a­bly with a tray icon...

  • A way to au­­to-up­­date the Mair­ix DB when new mail ar­rives. I am think­ing about do­ing it with in­­cron but have not done it yet.

So, here is the fi­nal ver­sion, put it some­where in your path, and use AL­T+F2 to search your mails :-)

#!/bin/sh
rm ~/Mail/.mairix* -f
mairix $*
dcop kmail KMailIface selectFolder /Local/inbox
dcop kmail KMailIface selectFolder /Local/mairix
kmail

New Bartleblog Feature: Menu Editor

Took a while to im­ple­men­t, but Bartle­Blog fi­nal­ly got a func­tion­al menu ed­i­tor:

bartleblog12.png

Right now, it on­ly works with the mootool­s-based menu gad­get, but I will start work­ing on the ya­hoo menu ver­sion in a mo­men­t.

The on­ly thing not work­ing is the pre­view but­ton, be­cause it needs more sup­port on the back­end side.

Today's first hour of hacking...

... has been all about UI.

I have al­ways had a prob­lem when writ­ing PyQt app­s: stock icon­s.

Which ones should I use? Where are they?

I usu­al­ly fished through the crys­talsvg icon set un­til I found one that seemed to be what I need­ed, and then copied it to my ap­p.

Sad­ly, that's an­noy­ing in sev­er­al ways:

  1. Since those are PNG icon­s, you need to find the right size.

  2. Not all icons are there for all sizes!

  3. Be­­cause of 2, I need to check three or four fold­ers to see all the icon­s.

So, I de­cid­ed to cut my loss­es, and see what else could be done. And here it is:

bartleblog11.png

I am now us­ing all SVG icon­s, from the rein­hardt set that will look equal­ly out of place in all OS­s, but which I like (and I think look awe­some with this re­laxed Domi­no the­me). And be­cause they are all SVG, I don't care about sizes, and they are all in the same place, and all is good.

And when­ev­er Oxy­gen is re­leased, all I need to do is switch the files around and that's that. Which is nice, too.

Of course there is a catch... it does look out of place, and I ex­pect many to find it ug­ly. So what, since I am the on­ly us­er of this ap­p! ;-)

Today's two hours of hacking

  • Done with the main blog con­­fig di­a­log.

  • Fixed a dozen bugs

  • Gen­er­ate the blog in a rea­­son­able place

  • Fixed a lot of UI bugs (tab or­der­s, sizes)

Still lots and lots of things to be done, tho.


Contents © 2000-2023 Roberto Alsina