Handling Ubuntu Default Programs (or Ubuntu default program handling sucks)

26Oct10

I recently experienced problem with Ubuntu 10.10, one that I never thought of before. During early last week I was wondering if Gedit could handle/open directory similar to VIM, Emacs and many others, so just called from Terminal 

gedit .

and it prompted with error, and that made me understand Gedit does not know how to work with directory. A few days went by and then I needed to use File Roller (Archive Manager) and after files extraction I would like to go to location of the files so just clicked ‘Show the Files’ button, and I was shocked to see it opened destination directory using Gedit. Testing with Chrome ‘Show in Folder’ ended up with the same result in Gedit screen. I was so desperate and was about to give up with Ubuntu, and I was planning to move data from my Ubuntu notebook. Google search did not give me much information, as I was not sure what to search for 😦

This morning, I did my ‘final’ google search and decided to do away with Ubuntu if I could not solve the problem. Luckily, this time the result is very pleasant, I found this “HowTo Change Default GNOME Text Editor or Any Other Default Program”   in Ubuntuforums.org (http://ubuntuforums.org/showthread.php?t=299086) described where information about default programs stored. Thank to Agen T for this very helpful document, and for easy access I copied the content here:

 

HowTo Change Default GNOME Text Editor or Any Other Default Program

How-To Change Default Text Editor (or any other default program)

The following step-by-step guide will make the program Scribes open every plain text document instead of Gedit. Instead of Scribes, you may use any other program.

Check if this file exists:

Code:
~/.local/share/applications/defaults.list

If so, open it, if not:

Code:
touch ~/.local/share/applications/defaults.list

Open ~/.local/share/applications/defaults.list and look for this entry:

Code:
[Default Applications]

If it does not exist, add it on top. Next, add the following below “[Default Applications]”:

Code:
text/plain=scribes.desktop

Your completed entry should look like this:

Code:
[Default Applications]
text/plain=scribes.desktop

Now run:

Code:
pkill nautilus

It is possible to set any mime type and any program that has a *.desktop entry. Find out your favorite program’s desktop entry by looking in this folder:

Code:
/usr/share/applications/

You need to know what mime type you want to have your new program open. text/plain means opening up any normal text file. If you would like Scribes to open ANY text file, you would substitute text/plain with text/* and follow everything else.

Why is this better than just right-click on file -> Open With? Because with the above, ALL plain text files will be opened by Scribes, not just ones that have a particular extension.

For more details on what programs are used for what mime types, see file:
/usr/share/applications/defaults.list
One easy way to replace a program like gedit would be to get all entries containing gedit, replace them with scribes, and add that list to ~/.local/share/applications/defaults.list.

This quit one-liner does exactly that, except that it posts the results in terminal and you will just have to copy/paste it into your file:

Code:
 grep gedit /usr/share/applications/defaults.list | sed s/gedit/scribes/g
__________________
Now I fixed my problem and learned how Ubuntu default program handling sucks. 
Oh, btw, the file I changed was via
vi ~/.local/share/applications/mimeapps.list 
Not the ‘defaults.list’ mentioned above, ‘defaults.list’ is default, but those changed later by apps will be in mimeapps.list 🙂

 

 

 

 

 

Advertisements


No Responses Yet to “Handling Ubuntu Default Programs (or Ubuntu default program handling sucks)”

  1. Leave a Comment

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: