Friday, June 27, 2008

Changing the default application to open up your iPod , or any device / file-type.

So I saw this question up on the forums ( www.ubuntuforums.org ), and I though about finding out what was causing this problem. So far I have found a small fix, with a minor issue and I'll go into that later in this How-To.

In order to associate and application ( like Songbird, Amarok ) with a file-type or device ( iPod, PNG, JPEG). The only thing is that the application we want to perform our task HAS to have a desktop entry ( Songbird.desktop ) located in the /usr/share/applications/directory. The file-type or device has to have a mime-type inside of /usr/share/mime directory ( e.g, /usr/share/mime/images/png.xml). The file that directs what application will open what file-types, is mimeapps.list. A file inside of ~/.local/share/applications/.

<<< Adding the proper entry >>>

Always start safe, and make sure you can fix yourself in case you screw something up.
So we are going to start by making a copy of the current mimeapps.list file.

cp ~/.local/share/applications/mimeapps.list ~/.local/share/applications/mimeapps.list.backup

Next open up the file with a text editor so that we can add our custom entry. You can change gedit for your favorite text editor.

sudo gedit ~/.local/share/applications/mimeapps.list

Add/Change the correct entry. In my case I had to add another entry since there was no entry
other than an entry from totem media player.

[Added Associations]
$MIME_TYPE=$NEW_APP.desktop;

To find out what $NEW_APP.desktop should be ( if necessary ).

ls /usr/share/applications/*.desktop | sed -e "s@/usr/share/applications/@@g" | less

Look for the name of the application you are using. So for this scenario I'm using songbird.
I ran the above command
and I was able to find in the list the applications desktop entry, it was Songbird.desktop

Next you have to figure out $MIME_TYPE ( if necessary )

find /usr/share/mime/ -mindepth 2 -maxdepth 2 -name "*" | sed -e "s@/usr/share/mime/@@g" -e "s@[.]xml@@g" | less

Keep in mind if you are changing this for a media player the entry is going to be
x-content/audio-player

In the end your new entry should look like this. Using Songbird as the choice of application
to handle the iPod.

[Added Associations]
x-content/audio-player=Songbird.desktop;

note: I had to make a new entry, don't change anything if it doesn't not pertain to iPod or Real Player control. In example
if the $MIME_TYPE doesn't match x-content/audio-player don't touch it.



Save the file, and restart nautilus by doing

WARNING RUNNING THE BELOW COMMAND WILL "FREEZE" YOUR COMPUTER FOR A SLIGHT MOMENT,
THIS IS ONLY HAPPENING BECAUSE NAUTILUS IS RESTARTING. WITHIN 10-15 SECONDS YOU
SHOULD HAVE CONTROL OF THE DESKTOP.



killall nautilus




Hope this works for you guys, let me know share it around, or tell me what to do to help
improve it. Appreciate it. I could make a video of my desktop while I do the guide here.
Don't know if that might help you guys better understand.









1 comment:

Francisco Jácomo Cunha said...

Hi Luis, thank you very much for dedicating your free time to help all of us that love and live Linux, your blog has helped me a lot in simple but necessary things, keep up the good work!