The Raspbian Update released on 13th May 2016 includes the Geany editor, although I already had this installed.

Unfortunately text files etc still open by default in Leafpad. The "Open With" menu doesn't include Geany and I can't seem to find any way to include Geany or make it the default.

2 Answers 2


The default GUI file manager on LXDE (the desktop environment used by Raspbian) is PCManFM. Unfortunately while that wiki page mentions "file associations", it doesn't explain how to customize them.

I don't use LXDE or PCManFM but I am fairly certain they use XDG protocols, which are open standards implemented by various DE's. An internet search for pcmanfm "file associations" led me to this page, which seems to confirm that, although it was written almost four years ago. There's a lot of explanation of various things in there that it still valid although there is now one more location for a mimeapps.list, ~/.config/mimeapps.list. Since user preferences should take precedence it is that or ~/.local/share/applications/mimeapps.list which should apply; I don't have a recent non-lite jessie image at hand so you may need to check if either or both already exist.

But before you bother you try xdg-mime; have a look at man xdg-mime. Geany has a system .desktop file, so the command would look something like:

xdg-mime default geany.desktop text/plain

No sudo here and do it as the user you want this to apply to.

If you aren't familiar with MIME types they're an internet standard; here's the official list of text/ ones. Covering all your bases is obviously going to be a bit tedious (text/plain just covers literal .txt files, I believe), and as far as I can tell we can't use some form of glob or regex directly here, but you can use a very long list, so here's a trick pilfered from the Arch linux wiki:

xdg-mime default geany.desktop $(grep "^text" /usr/share/mime/types)

I tried this here and they ended up in ~/.config/mimeapps.list. It's more than a hundred text/... types.

I don't know whether you will have to reopen anything (the file manager, the LXDE session itself) in order for this to apply; you shouldn't have to log in and out again (except to the extent that you will if you are using a display manager and you want to restart LXDE, but I suspect the most you'll have to do is restart pcmanfm).

Possible Gotcha

Once that's done Geany should be in the list under "Open with" and you can set it via the GUI as the preferred application. Except that if it isn't there already, this implies it doesn't list that MIME type in its .desktop file. You can customize that by finding it in /usr/share/applications and copying it to ~/.local/share/applications, then modifying the copy to include the long list of MIME types...

Beware also the xdg-mime invocation will have included all source code types, since they are text, so if you have different applications you prefer to use for those and you can't choose different defaults via PCManFM you'll have to do some tweaking of mimeapps.list.


I have actually resolved my problem, but followed up so many leads I was unsure what the actual "fix" is. The documentation on LXDE Desktop Environment and PCManFM File Manager is not particularly helpful.

I just repeated on another Pi, and am listing the solution.

I selected a text file in PCManFM and selected Open with in the context menu. Geany was missing from the Installed Applications so I selected Custom Command Line and entered /usr/bin/geany %f and entered Application name Geany.

Geany now appears in the context menu and in its correct place in the Open With menu.

This appeared to generate .config/mimeapps.list with the following content

[Added Associations]

[Default Applications]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.