Switch from gedit as the default application for text files in Gnome 3

When opening a shell script attachment in Thunderbird, Gnome defaulted to Gedit. I'd like to use Geany as my default app for text files, however there was no option to set a default app for text files in "System Settings" > "Details" > "Default Applications" in Ubuntu 12.04. Here's what worked for me:

$ echo "[Default Applications]" >> ~/.local/share/applications/defaults.list
$ sed -n 's/gedit/geany/p' /usr/share/applications/defaults.list >> ~/.local/share/applications/defaults.list

NOTE: In my case, I didn't already have "~/.local/share/applications/defaults.list", YMMV.

The above produced the following defaults.list, making Geany default for my uid:

$ cat ~/.local/share/applications/defaults.list
[Default Applications]
application/x-perl=geany.desktop
text/plain=geany.desktop
text/x-chdr=geany.desktop
text/x-csrc=geany.desktop
text/x-dtd=geany.desktop
text/x-java=geany.desktop
text/mathml=geany.desktop
text/x-python=geany.desktop
text/x-sql=geany.desktop

Tested on Ubuntu 12.04 LTS with Gnome 3.2.1 (according to "gnome-session --version"), but should probably work on any distro using Gnome 3 (e.g. Debian Testing/Unstable, etc).

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).