Don’t call me DOM

15 September 2005

Integrating a new URIs scheme handler to Gnome and Firefox

Filed under:

As DanC mentioned, we’ve been playing with configuring Firefox in Gnome to use tel: URIs with our Vonage service; in short, this means you can click on a link à la tel:+1.555.123.4567 and get your Vonage phone calls the said the number. In practice, your phone starts ringing, and once you pick it up, it dials the said number.

Most of the actual work is done by Click 2 Call which offers a Web interface to your Vonage line. But getting integrated nicely in your browsing/desktop experience is fun.

So, how do you get a new URI scheme to be handled by Firefox or Gnome?

Well, first, getting a new URI scheme to be handled by Firefox is equivalent as getting it handled for Gnome, since for some reason, Firefox uses the generic gnome-open command to handled unknown URI schemes. I haven’t been able to find how or why, so I don’t know if that’s Debian specific or if this is true for any Firefox running on Linux et al.

Getting a new URI handler in Gnome is not necessarily well-documented, but once you know, it’s very easy; the set of three commands below is all that’s needed to get my local script vonage-call to be added as the handler for tel: URIs:

gconftool-2 -t string -s /desktop/gnome/url-handlers/tel/command "bin/vonage-call %s"
gconftool-2 -s /desktop/gnome/url-handlers/tel/needs_terminal false -t bool
gconftool-2 -t bool -s /desktop/gnome/url-handlers/tel/enabled true

The same kind of commands allows to add any kind of URI handler, like my MID dereferencer, my urn:isbn dereferencer or the x-edit bookmarklet hack.

So, what does this vonage-call script do? Well, most of the actual work is done by a simple curl call to the said Web interface; but I’ve added a bit of interfacing to be improve the look & feel of the operation, using zenity, Gnome’s equivalent of xdialog.

So, when you call vonage-call without argument, you’re asked for a phone number to call:
Screenshot of the dialog asking to enter the phone number to be called

Once entered (or directly if you’ve followed a tel: link), you’re asked for confirmation :
Screenshot of the dialog asking confirmation for the call

And eventually, there is even a progress bar for the few seconds it takes to run the curl command:
Screenshot of the progress bar

To finalize the integration of this small script into the desktop, and following Sun’s documentation on Gnome integration, I’ve managed to add an entry in my Applications->Internet menu… with great pain, I must confess.

The key to be able to use a personalized menu per-User on gnome is to have the following file created .gnome2/vfolders/applications.vfolder-info

  <!-- path doesn't understand $HOME or ~/ ; maybe it would understand it as a relative path to $HOME? didn't test -->

This basically instructs Gnome that it can write into the said directory — make sure to actually create it (mkdir -p .gnome2/vfolders/applications) — when you try to personalize the menu with Nautilus; otherwise, you get a permission denied error, since Nautilus would try to modify the content of the directory defined at a higher level in /etc/gnome-vfs-2.0/applications-all-users.vfolder-info; once this is done (and despite the complete lack of documentation of this), you can use Nautilus to add (and probably remove) launchers in your menu. This is with Gnome 2.8; I’ve read that Gnome 2.12 fixes some of the menu-editing difficultiess, so this may be easier if you’re running a bleeding edge version.

A launcher in Gnome (and KDE) is a simple .desktop file that lists a set of well-defined properties; here is what I’ve used for my little script vonage.desktop that I placed in the directory created above, .gnome2/vfolders/applications:

[Desktop Entry]
Name=Vonage caller
Comment=Call phone numbers using Vonage

This can actually be created with the graphical interface, I think: right-click on your desktop, create a new launcher bound to the right command and selecting the right icon; once done, open the “Applications” virtual folder in Nautilus (either from the virtual “Start here” folder, or using the applications-all-users:// URI (sigh!)), and copy your new launcher in it; the right thing should happen: List of items in the Internet menu in Gnome, with the Vonage caller script added

Well, that’s about it; there is still a bit too much of magic for my liking, but the fact that this is doable, and even fairly easy once you know the magic is already pretty sweet!

8 Responses to “Integrating a new URIs scheme handler to Gnome and Firefox”

  1. Sean Says:

    Thanks for the HOWTO on adding url-handlers in GNOME! :) I was able to add an url-handler for azureus magnet links thanks to your help!

  2. Anonymous Says:

    Can you share how you got firefox and Azureus work, thx

  3. Ralph Corderoy Says:

    Many thanks for the article. Just what I was trying to find out in order to by-pass Firefox 3’s awful bookmarks manager. BTW, is the correct replacement for the broken link in the article.

  4. Nathan Says:

    Thanks for reference. I was pretty sure it was this simple, and that does the trick! Although my interest was in regard to getting the gnome panel menus to use Thunar instead of Nautilus and it was as simple as defining a ‘file’ url-handler!

  5. Rob Parker » Blog Archive » Getting Spotify URIs recognised system-wide on GNOME distros Says:

    […] on Gnome; sadly I could find no graphical way of doing this, but after a bit of searching, I found this page, which revealed it was a simple as adding a few keys to GConf. So I adapted to method for the […]

  6. How to: Spotify and xdg-open « Team Unreliable Pollution Says:

    […] /archives/2005/09/integrating-a-new-uris-scheme-handler-to-gnome-and-firefo… […]

  7. Wel. R. Braga » Iniciando uma sessão de chat Skype a partir do Firefox Says:

    […] Hazael-Massieux. Integrating a new URIs scheme handler to Gnome and Firefox. /archives/2005/09/integrating-a-new-uris-scheme-handler-to-gnome-and-firefo… Phillip Kolmann. […]

  8. Python URL handlers for web browsers - Programmers Goodies Says:

    […] GNOME […]

Picture of Dominique Hazael-MassieuxDominique Hazaël-Massieux ( is part of the World Wide Web Consortium (W3C) Staff; his interests cover a number of Web technologies, as well as the usage of open source software in a distributed work environment.