URL protocol handlers in basic Ubuntu Desktop












16















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 gconf-editor, I see a key /desktop/gnome/url-handlers/apt whose value is apturl "%s" and it's enabled. 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 stuff unrelated to this case) loaded.



Update



Another way to “register” a protocol handler is with *.desktop files and their MIME-Type; e.g. 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 as usual with user desktop‑files, should override the one in /usr/share/applications/.



Maybe 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.










share|improve this question




















  • 1





    This may help: unix.stackexchange.com/a/100736

    – Todd Owen
    Oct 11 '14 at 1:34
















16















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 gconf-editor, I see a key /desktop/gnome/url-handlers/apt whose value is apturl "%s" and it's enabled. 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 stuff unrelated to this case) loaded.



Update



Another way to “register” a protocol handler is with *.desktop files and their MIME-Type; e.g. 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 as usual with user desktop‑files, should override the one in /usr/share/applications/.



Maybe 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.










share|improve this question




















  • 1





    This may help: unix.stackexchange.com/a/100736

    – Todd Owen
    Oct 11 '14 at 1:34














16












16








16


4






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 gconf-editor, I see a key /desktop/gnome/url-handlers/apt whose value is apturl "%s" and it's enabled. 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 stuff unrelated to this case) loaded.



Update



Another way to “register” a protocol handler is with *.desktop files and their MIME-Type; e.g. 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 as usual with user desktop‑files, should override the one in /usr/share/applications/.



Maybe 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.










share|improve this question
















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 gconf-editor, I see a key /desktop/gnome/url-handlers/apt whose value is apturl "%s" and it's enabled. 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 stuff unrelated to this case) loaded.



Update



Another way to “register” a protocol handler is with *.desktop files and their MIME-Type; e.g. 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 as usual with user desktop‑files, should override the one in /usr/share/applications/.



Maybe 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.







gnome dconf url






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 21 '16 at 17:46









declension

28428




28428










asked Aug 21 '14 at 7:04









Hibou57Hibou57

6601622




6601622








  • 1





    This may help: unix.stackexchange.com/a/100736

    – Todd Owen
    Oct 11 '14 at 1:34














  • 1





    This may help: unix.stackexchange.com/a/100736

    – Todd Owen
    Oct 11 '14 at 1:34








1




1





This may help: unix.stackexchange.com/a/100736

– Todd Owen
Oct 11 '14 at 1:34





This may help: unix.stackexchange.com/a/100736

– Todd Owen
Oct 11 '14 at 1:34










2 Answers
2






active

oldest

votes


















9














Open ~/.local/share/applications/mimeapps.list and add a line like:



x-scheme-handler/apt=apturl.desktop





share|improve this answer
























  • Ya, I could figure it for HTTP, MAILTO and some others.

    – Hibou57
    Feb 26 '16 at 20:29











  • There is no such folder. I did a search from root, and didn't find it.

    – Vlas Bashynskyi
    Aug 12 '16 at 13:58











  • @VlasBashynskyi, the location of mimeapps.list may vary. I would suggest to run a search for the file name.

    – Hibou57
    Aug 16 '16 at 14:24



















4














xdg-mime



Maybe more elegant (in this example I use "apt", change it for any other scheme):




  1. Check registered mime-types in /usr/share/applications/defaults.list.

  2. Add the apt.desktop file to ~/.local/share/applications/ or /usr/share/applications/ (here examples).

  3. Build cache database of MIME types handled by desktop files: update-desktop-database


  4. Register a protocol with



    xdg-mime default apt.desktop x-scheme-handler/apt`


    This will append the new MIME Type for the scheme to ~/.local/share/applications/mimeapps.list. You can register the new mime-type for all users on the system sudo xdg-mime install --mode system <xml file>.




Test with xdg-open "apt://foo.bar"






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f514125%2furl-protocol-handlers-in-basic-ubuntu-desktop%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    9














    Open ~/.local/share/applications/mimeapps.list and add a line like:



    x-scheme-handler/apt=apturl.desktop





    share|improve this answer
























    • Ya, I could figure it for HTTP, MAILTO and some others.

      – Hibou57
      Feb 26 '16 at 20:29











    • There is no such folder. I did a search from root, and didn't find it.

      – Vlas Bashynskyi
      Aug 12 '16 at 13:58











    • @VlasBashynskyi, the location of mimeapps.list may vary. I would suggest to run a search for the file name.

      – Hibou57
      Aug 16 '16 at 14:24
















    9














    Open ~/.local/share/applications/mimeapps.list and add a line like:



    x-scheme-handler/apt=apturl.desktop





    share|improve this answer
























    • Ya, I could figure it for HTTP, MAILTO and some others.

      – Hibou57
      Feb 26 '16 at 20:29











    • There is no such folder. I did a search from root, and didn't find it.

      – Vlas Bashynskyi
      Aug 12 '16 at 13:58











    • @VlasBashynskyi, the location of mimeapps.list may vary. I would suggest to run a search for the file name.

      – Hibou57
      Aug 16 '16 at 14:24














    9












    9








    9







    Open ~/.local/share/applications/mimeapps.list and add a line like:



    x-scheme-handler/apt=apturl.desktop





    share|improve this answer













    Open ~/.local/share/applications/mimeapps.list and add a line like:



    x-scheme-handler/apt=apturl.desktop






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Feb 26 '16 at 1:16









    angelangel

    10612




    10612













    • Ya, I could figure it for HTTP, MAILTO and some others.

      – Hibou57
      Feb 26 '16 at 20:29











    • There is no such folder. I did a search from root, and didn't find it.

      – Vlas Bashynskyi
      Aug 12 '16 at 13:58











    • @VlasBashynskyi, the location of mimeapps.list may vary. I would suggest to run a search for the file name.

      – Hibou57
      Aug 16 '16 at 14:24



















    • Ya, I could figure it for HTTP, MAILTO and some others.

      – Hibou57
      Feb 26 '16 at 20:29











    • There is no such folder. I did a search from root, and didn't find it.

      – Vlas Bashynskyi
      Aug 12 '16 at 13:58











    • @VlasBashynskyi, the location of mimeapps.list may vary. I would suggest to run a search for the file name.

      – Hibou57
      Aug 16 '16 at 14:24

















    Ya, I could figure it for HTTP, MAILTO and some others.

    – Hibou57
    Feb 26 '16 at 20:29





    Ya, I could figure it for HTTP, MAILTO and some others.

    – Hibou57
    Feb 26 '16 at 20:29













    There is no such folder. I did a search from root, and didn't find it.

    – Vlas Bashynskyi
    Aug 12 '16 at 13:58





    There is no such folder. I did a search from root, and didn't find it.

    – Vlas Bashynskyi
    Aug 12 '16 at 13:58













    @VlasBashynskyi, the location of mimeapps.list may vary. I would suggest to run a search for the file name.

    – Hibou57
    Aug 16 '16 at 14:24





    @VlasBashynskyi, the location of mimeapps.list may vary. I would suggest to run a search for the file name.

    – Hibou57
    Aug 16 '16 at 14:24













    4














    xdg-mime



    Maybe more elegant (in this example I use "apt", change it for any other scheme):




    1. Check registered mime-types in /usr/share/applications/defaults.list.

    2. Add the apt.desktop file to ~/.local/share/applications/ or /usr/share/applications/ (here examples).

    3. Build cache database of MIME types handled by desktop files: update-desktop-database


    4. Register a protocol with



      xdg-mime default apt.desktop x-scheme-handler/apt`


      This will append the new MIME Type for the scheme to ~/.local/share/applications/mimeapps.list. You can register the new mime-type for all users on the system sudo xdg-mime install --mode system <xml file>.




    Test with xdg-open "apt://foo.bar"






    share|improve this answer






























      4














      xdg-mime



      Maybe more elegant (in this example I use "apt", change it for any other scheme):




      1. Check registered mime-types in /usr/share/applications/defaults.list.

      2. Add the apt.desktop file to ~/.local/share/applications/ or /usr/share/applications/ (here examples).

      3. Build cache database of MIME types handled by desktop files: update-desktop-database


      4. Register a protocol with



        xdg-mime default apt.desktop x-scheme-handler/apt`


        This will append the new MIME Type for the scheme to ~/.local/share/applications/mimeapps.list. You can register the new mime-type for all users on the system sudo xdg-mime install --mode system <xml file>.




      Test with xdg-open "apt://foo.bar"






      share|improve this answer




























        4












        4








        4







        xdg-mime



        Maybe more elegant (in this example I use "apt", change it for any other scheme):




        1. Check registered mime-types in /usr/share/applications/defaults.list.

        2. Add the apt.desktop file to ~/.local/share/applications/ or /usr/share/applications/ (here examples).

        3. Build cache database of MIME types handled by desktop files: update-desktop-database


        4. Register a protocol with



          xdg-mime default apt.desktop x-scheme-handler/apt`


          This will append the new MIME Type for the scheme to ~/.local/share/applications/mimeapps.list. You can register the new mime-type for all users on the system sudo xdg-mime install --mode system <xml file>.




        Test with xdg-open "apt://foo.bar"






        share|improve this answer















        xdg-mime



        Maybe more elegant (in this example I use "apt", change it for any other scheme):




        1. Check registered mime-types in /usr/share/applications/defaults.list.

        2. Add the apt.desktop file to ~/.local/share/applications/ or /usr/share/applications/ (here examples).

        3. Build cache database of MIME types handled by desktop files: update-desktop-database


        4. Register a protocol with



          xdg-mime default apt.desktop x-scheme-handler/apt`


          This will append the new MIME Type for the scheme to ~/.local/share/applications/mimeapps.list. You can register the new mime-type for all users on the system sudo xdg-mime install --mode system <xml file>.




        Test with xdg-open "apt://foo.bar"







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 22 at 19:29

























        answered Apr 8 '18 at 19:04









        Pablo BianchiPablo Bianchi

        2,4751532




        2,4751532






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f514125%2furl-protocol-handlers-in-basic-ubuntu-desktop%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            數位音樂下載

            When can things happen in Etherscan, such as the picture below?

            格利澤436b