OK I found it!So I will answer here.
FOR UBUNTU(>=11.04)
Gconf settings(/desktop/gnome/url-handlers
) didn't do anything since as of Natty the file-open functionality is handled by gvfs-open
, which doesn't use gconf settings. Rather, gvfs-open looks at the ".desktop" files bundled with each application to determine what file types can be handled.if it is not installed, run :
sudo apt-get install gvfs-bin
In all x-scheme handler urls( like irc://, xmpp://, sip://, aim://) are handled by purple-url-handler.We are going to create a desktop file for it.
gksudo gedit /usr/share/applications/purple-url-handler.desktop
& put following content in it:
[Desktop Entry]
Name=Purple URL Handler
GenericName=Internet Messenger
Comment=URL handler forGoogle Talk, Jabber/XMPP, MSN, Yahoo and more
Exec=purple-url-handler %U
Icon=pidgin
StartupNotify=true
Terminal=false
Type=Application
MimeType=x-scheme-handler/irc;
Categories=Network;InstantMessaging;
X-Ubuntu-Gettext-Domain=pidgin
Now to make irc:// links open with purple-url-handler run :
xdg-mime default purple-url-handler.desktop x-scheme-handler/irc
This informator is stored in ~/.local/share/applications/mimeapps.list.
Now when you click any irc:// link in chromium for the first time, the following prompt will appear:
Select remember my choice & launch application. If you are already logged in it will open the room in pidgin.
DONE!
The previous two answers didn't work for me:
(setq process-connection-type nil)
broke org-plot/gnuplot
setsid xdg-open ...
worked for a while, but then it stopped for some reason.
Now I use setsid -w
, which supposedly makes setsid
wait until the called program finishes.
If someone would need it, I use this with AUCTeX (and I found this question while trying to fix AUCTeX behavior on Arch linux), and my TeX-command-list
is set to
(quote
(
;; ...
("View" "setsid -w xdg-open %s.pdf" TeX-run-command t t :help "Run Text viewer")
;; ...
)
It seems to work fine for now...
Best Answer
xdg-open basically just looks to see which desktop environment you have and then runs gnome-open, gvfs-open, xfce-open, etc. See below for desktop environment specific instructions...
Gnome
Gnome uses the gnome-open program which uses gconf to store everything. For example on my machine with Ubuntu 10.10 running gnome-open irc://blah opens up xchat because xchat includes a gconf setting patch to add an irc:// handler.
This shows how gnome does this, with a gconf settings in
/desktop/gnome/url-handlers/
. Seexchat-2.8.8/src/common/dbus/apps_xchat_url_handler.schemas
as an example.KDE
For KDE you should look at the .protocol files in /usr/share/kde4/services/, create a new one for your new protocol and put it in ~/.kde/share/kde4/services/, if it's super useful then consider adding it to the package as a fix for other users.
KDE is using kde-open or kfmclient depending on what's available and what version of KDE you have.
XFCE
XFCE uses a program called exo-open, this program doesn't have any way to configure it or add uri handlers. Looking through the source code shows that is uses desktop files to specify only three types of programs. TerminalEmulator, WebBrowser and EmailClient.
With XFCE4 (and probably also others) it is possible to configure xdg-open to define a custom protocol handler. In some you have to create/edit the following files:
~/.local/share/applications/protocolhandler.desktop ~/.local/share/applications/mimeapps.list
An example adding a handler for the ed2k protocol is provided at stackexchange.com2.