18

I'm trying to associate a custom application to a file type in GNOME 3 (FC15). In GNOME 2 one could go in the "Open with" pane of the file properties dialog and add a custom command there. The custom command edit box seems to have disappeared from the "Open with" pane in GNOME 3, so I was wondering if there is some workaround to manually assign the application.

In other words, from which file/directory does GNOME pull out that application list? How do I add a custom one?

6 Answers 6

10

I know this is late but...Fist, create a desktop file in ~/.local/share/applications/ for example sublime.desktop would be something like ~/.local/share/applications/sublime.desktop with the following content:

[Desktop Entry]
Keywords=Plaintext;Write;Programming;Syntax;Ruby;HTML
Categories=;
Comment=sublime
Exec=sublime_text %U
Hidden=false
Icon=icon-name
Name=sublime
Terminal=false
Type=Application
Version=1.0
StartupNotify=true
MimeType=text/plain;text/html;application/ruby;

Then... if you edit ~/.local/share/applications/mimeapps.list you will see the content type text/html edit it like so:

[Default Applications]
x-scheme-handler/http=firefox.desktop
x-scheme-handler/https=firefox.desktop
x-scheme-handler/ftp=firefox.desktop
x-scheme-handler/chrome=firefox.desktop
text/html=sublime.desktop
application/x-extension-htm=sublime.desktop
application/x-extension-html=sublime.desktop
application/x-extension-shtml=firefox.desktop
application/xhtml+xml=firefox.desktop
application/x-extension-xhtml=firefox.desktop
application/x-extension-xht=firefox.desktop

[Added Associations]
x-scheme-handler/http=firefox.desktop;
x-scheme-handler/https=firefox.desktop;
x-scheme-handler/ftp=firefox.desktop;
x-scheme-handler/chrome=firefox.desktop;
application/x-extension-htm=firefox.desktop;
application/x-extension-html=firefox.desktop;
application/x-extension-shtml=firefox.desktop;
application/xhtml+xml=firefox.desktop;
application/x-extension-xhtml=firefox.desktop;
application/x-extension-xht=firefox.desktop;
application/x-yaml=sublime-1.desktop;

[Removed Associations]
text/html=firefox.desktop;gedit.desktop;

You can of-course change as many or as little as you want and you can also add as many or as little as you want to the desktop files MimeType for example application/python, application/x-ruby, text/ruby, text/x-python or dozens of other variants... though sticking to simple types should be alright for example application/python and application/ruby both work on my GNOME 3.2 install.

9

There is the answer: http://forums.fedoraforum.org/showthread.php?t=263501

I have Gnome3 and there is "Open with" pane :) You also go to proporties and there is "Open with" tab.

Edit: You should look on https://bbs.archlinux.org/viewtopic.php?id=118966. Your applications should show on list, if you add a *.desktop file associated with your application to /usr/share/applications or ~.local/share/applications/ directory. Exec should like this: Exec=yourprogram %U

3
  • Thanks for your answer but that is not what I am asking. I know that there is an "Open with" pane, what is missing is the "custom command" edit box. I will rephrase my question accordingly
    – nico
    Commented Aug 2, 2011 at 12:57
  • Seems to work fine, I'll still have to figure out a couple of things but it does the job. Thank you
    – nico
    Commented Aug 8, 2011 at 5:59
  • 5
    Please don't answer with just a link. At the least, summarize the solution in the body of your answer. You can link for further reading, but that is not a substitute for providing an inline answer. Thanks.
    – Caleb
    Commented Apr 29, 2012 at 5:11
6

In newer versions of Gnome, you don't need to manually edit anything now. Right-click on the file you want to open, select Properties, go to the Open With tab, and select the default application you want to use...then click "Set as default".

4

gnome-panel still has the old gnome2 command to do this.

Enter:

gnome-desktop-item-edit ~/.local/share/applications/ --create-new

Then use your-command %U as the command.

1
  • Thanks Steve, surely that is another way, albeit less viable. By the way you can also pull out that panel from alacarte
    – nico
    Commented Apr 29, 2012 at 8:53
0

In Gnome 3.4.2 there is another way to change defaults for web, mail, calendar, music, video and photos. You have to use the gnome-control-center (or Details in Activities menu). Then go to --> Default Applications

1
  • Thank you for your answer, although that is not what I was asking. I wanted to change the default application for an arbitrary file type other than web, music etc.
    – nico
    Commented Feb 16, 2014 at 11:09
-2

I believe you can modify the entries in this file: /usr/share/gnome/applications/defaults.list.

2
  • 1
    How does this answer the question? What should one do with this file? On what systems does changing this file apply (on my Fedora 19 with gnome 3.8, this file doesn't exist)?
    – drs
    Commented May 21, 2014 at 16:14
  • This file doesn't exist on my Fedora 19 GNOME 3 install, so I don't think it's correct advice.
    – slm
    Commented May 21, 2014 at 16:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .