…with an open minded approach

Posts tagged “xdg

Lubuntu/lxde – showing and opening eml files with thunderbird

Scenario:

You have windows xp with Thunderbird, and you have a habbit of organizing your emails by saving them into folders as my_email.eml files.

Then some day, windows xp starts to bog-down, and you decide it might be a good moment to try that “linux” your nephew says it’s so good with old pcs

So your nephew puts Lubuntu (which is like ubuntu with lxde instead of gnome) installed side-by-side with the windows xp, and also installs Thunderbird inside your linux.

You explain to your nephew that you want to:

  1.  be able to see your same emails from both linux-thunderbird or from windows-thunderbird (just in case)
  2. keep opening and saving your emails as files inside folders

Solution for 1.

Explained in this post from askubuntu.com

Basically, maintain your existing thunderbird profile in windows, and in linux, configure $HOME/.thunderbird/profile.ini to point to the same windows profile

Solution for 2.

Now this is more tricky and it is the reason for sharing this post with anyone interested…

It comes in 2 parts:

Saving an email as a file

As the title already says it, you can select one email inside Thunderbird, and then click    File / Save as / File  and save it as an .eml file – it’s as simple as it looks
Seems like some people do this to organize their emails in a folder-hierarchy together with other documents… it might be a good strategy for a small company for example, to keep documented and stored in shared folders the important agreements made by company members in emails… allowing for future reviews made by any employe who might not actually be part of the mailing-list… I  imagine a kind of an history-archive of past businesses or sort of… well, whatever usefullness it might have 🙂

Opening an email from a file

This is the interesting part – in windows you had the habbit of simply opening up an explorer window of a folder, and then click-click the my_email.eml file, and thunderbird would open up the email – great.

Now in lubuntu, you open up an pcmanfm window of a folder, and when you click-click  my_email.eml it gets open in gedit…

Your nephew says for you to go have a coffee while he fixes up things, and after some hours of reading and searching, your nephew ends up discovering some interesting things about what is going on between pcmanfm and thunderbird that explain why it did not opened as expected.

He first sets the option “Open With…” and makes Thunderbird the “default” the default application for .eml files – that was quick and easy, but it did not worked as expected: when click-clicked again over my_email.eml, nothing happens…

When pcmanfm tries to open my_email.eml, it calls the associated program, which by default is now Thunderbird

To know how to call Thunderbird, it reads the file:

/usr/share/applications/thunderbird.desktop

that indicates the Exec field:

Exec=thunderbird %u

So pcmanfm will execute

thunderbird %u

, where the %u is the URL of the my_email.eml file (see [1]) which is something like  file:///mnt/Data/my_email.eml

And here is the problem – Thunderbird is not expecting an URL argument, it expects a PATH argument (like /mnt/Data/my_email.eml)

To fix it, you can edit as root “/usr/share/applications/thunderbird.desktop” and where it puts

Exec=thunderbird %u

add a %f in front of %u  (see [1] ):

Exec=thunderbird  %f  %u

And from now on, the click-click of .eml files inside pcmanfm works as expected and opens up Thunderbird

BrainStorming and todos

The file “/usr/share/applications/thunderbird.desktop” is defined by freedesktop.org as are the related utilities xdg-open xdg-mime, xdg-…

What was made was a litle hack for thunderbird.desktop launcher to accept the %f argument sent by pcmanfm, instead of only getting the %u which would not work for this case

In the end although my_email.eml was opening well with thunderbird, it was still not being shown with the thunderbird icon inside pcmanfm – that is something to read about in freedesktop.org or maybe google, and try to fix manually – basically it should be something like associate to the mime-type of .elm files to the icon of thunderbird

Note that the xdg mechanisms are implemented by all desktop managers like gnome, kde, xfce, e17, lxde, … so this info is not limited to lubuntu/lxde, it is valid for all desktop managers. The idea is that each desktop manager, whatever it is, implements the “standards” of freedesktop and so obeys seeminglessly the xdg-open, xdg-mime, xdg-icon orders… this is why the same applications show up in the same place in the menu, with different desktop managers 🙂

Hope it helps someone – if it does, drop a comment, it cheers me up 🙂

[1] For more info about the Exec line, see http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html