URL protocol handlers in basic Ubuntu Desktop

Posted by Hibou57 on Ask Ubuntu See other posts from Ask Ubuntu or by Hibou57
Published on 2014-08-21T07:04:56Z Indexed on 2014/08/21 10:30 UTC
Read the original article Hit count: 302

Filed under:
|
|

There was a way to register URL protocol handlers with Gconf, which is now obsolete and there seems to be no way to do the same with DConf (or Gsettings, its recommended wrapper).

How do one properly register an URL protocol handlers since DConf?

Additionally, something looks strange to me (as I don't understand it), on my Ubuntu 12.04

The protocol apt:// should be handled by the apturl command. It is so with my Opera browser, but only because I added this specific association using the browser's configuration facility. Otherwise, in the rest of the environment:

  • Running xdg-open apt://foo.bar opens elinks (my www-browser alternative).
  • Running gnome-open apt://foo.bar opens the Software?Center.
  • Opening gcong-editor, I see a key /desktop/gnome/url-handlers/apt whose value is apturl "%s" and its enable. This configuration seems to be ignored, which is reasonably expected, as GConf is considered obsolete.
  • Opening dconf-editor, I can't see anything related to URL handlers or protocols in /desktop/gnome

It looks a bit messy to my eyes (just teasing with this wording, nothing bad)

What's underneath?

Side note: I'm looking for something which preferably works even when the full desktop environment is not loaded, like when running an i3wm session with only gsettings-daemon (and other stuffs unrelated to this case) is loaded.

Update

Another way to “register” a protocol handler is with *.desktop files and their MIME-Type; ex. MimeType=application/<the-protocol>;.

I found a /usr/share/applications/ubuntu-software-center.desktop with this content:

[Desktop Entry]
Name=Ubuntu Software Center
GenericName=Software Center
Comment=Lets you choose from thousands of applications available for Ubuntu
Exec=/usr/bin/software-center %u
Icon=softwarecenter
Terminal=false
Type=Application
Categories=PackageManager;GTK;System;Settings;
MimeType=application/x-deb;application/x-debian-package;x-scheme-handler/apt;
StartupNotify=true
X-Ubuntu-Gettext-Domain=software-center
Keywords=Sources;PPA;Install;Uninstall;Remove;Purchase;Catalogue;Store;

This one explains why gnome-open apt://foo.bar opens the Software?Center instead of apturl.

So I installed this apturl.desktop in ~/.local/share/applications:

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=false
Exec=/usr/bin/apturl %u
Name=APT-URL
Comment=APT-URL handler
Icon=
Categories=Application;Network;
MimeType=x-scheme-handler/apt;

After update-desktop-database and even after rebooting, both xdg-open and gnome-open still do the same and ignore this user desktop file, which is usual, should override the other in /usr/share/applications/.

May be there is something special with desktop files specifying x-scheme-handler MIME type and they are not handled the usual way.

The desktop-file way does not answer the question.

© Ask Ubuntu or respective owner

Related posts about gnome

Related posts about dconf

  • Editing /.config/dconf/user

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I am having a problem with Gnome3 (actually, I have it set to fallback mode, or Gnome 2). I have two displays and I need an X screen (I used nvidia-xconfig and nvidia-settings to do this) for each screen. However, every time I either restart X or log in, Gnome seems to be adding the objects values… >>> More

  • Did "sudo dconf reset -f /org/compiz". Now ccsm settings ignored

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I executed: sudo dconf reset -f /org/compiz Now changing settings in CompizConfig Settings Manager (ccsm) has no effect. For example, changing the number of desktops has no effect. I tried purging and reinstalling ccsm but it didn't help. Incidentally, where is the documentation for this sort… >>> More

  • disable all hotkeys with dconf-editor

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I'm building a deb package that will create a kiosk user account. When you login to this account, the browser automatically starts and navigates to a pre-given website. Also all the hotkeys should be disabled except for one you defined. Now I'm at the part that the browser starts and my disable script… >>> More

  • Do dconf use EXI binary XML?

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    A question came to my mind reading an answer to the question What are the differences between gconf and dconf?. In an reply to the above question, Oli said: Binary read access is far faster than parsing XML. However, there exist a W3C recommendation for binary XML, since 2010: Efficient XML… >>> More

  • Upgrade to 14.04 broke gsettings

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I have a cron job which runs every 30 minutes that changes the background image by running this bash script: #!/bin/bash export DISPLAY=:0 export GSETTINGS_BACKEND=dconf wpdir="/home/username/Pictures/wallpapers/" prefix="file://" file=`ls $wpdir | shuf -n 1` gsettings set org.gnome.desktop.background… >>> More