4

I'm trying to configure my Linux environment to open obsidian:// URIs using the Obsidian app (see Using Obsidian URI).

This is the flow I'm using. I'm doing this on a clean Ubuntu machine to make sure it reproduces:

  1. The Obsidian.AppImage file is stored in ~/obsidian alongside an icon.jpg file. The AppImage file has execute permissions.

  2. This is my ~/.local/share/applications/obsidian.desktop file's content:

    [Desktop Entry]
    Name=Obsidian
    Exec=/home/rachum/obsidian/Obsidian.AppImage %u
    Terminal=false
    Type=Application
    Icon=/home/rachum/obsidian/icon.png  
    StartupWMClass=obsidian
    X-AppImage-Version=0.8.15
    Comment=Obsidian
    Categories=Office;
    MimeType=text/html;x-scheme-handler/obsidian;
    
  3. I've run update-desktop-database ~/.local/share/applications/

  4. Using xdg-open works as intended:

    xdg-open "obsidian://new?vault=notes&name=note&content=content"
    

    This command line opens the Obsidian app with the new note and content.

  5. In Firefox (preinstalled), typing the above URI into the URL bar also opens the Obsidian app with the new note and content.

  6. I installed Google Chrome by downloading the .deb file from the official Chrome site and running dpkg -i <.deb file>

  7. Typing the above URI in Chrome just redirects me to a Google search for "obsidian://new?vault=notes&name=note&content=content".

Why is Chrome not respecting the XDG configuration?


Update #1: adding more details to answer comment.

My ~/.local/share/applications/mimeapps.list file looks like this:

[Default Applications]
x-scheme-handler/obsidian=obsidian.desktop

My ~/.local/share/applications/mimeinfo.cache file looks like this:

[MIME Cache]
text/html=obsidian.desktop;
x-scheme-handler/obsidian=obsidian.desktop;
5
  • have you updated ~/.local/share/applications/mimeapps.list ?
    – binarysta
    Sep 19 '21 at 14:20
  • @binarysta - yes, see update #1.. Sep 19 '21 at 15:33
  • define "a clean Ubuntu machine" Sep 28 '21 at 4:15
  • I'm creating a fresh Ubuntu droplet in Digital Ocean, installing GNOME and then proceeding to the steps described above. Sep 28 '21 at 16:07
  • I would try and reproduce with a live install DVD inside a VM, because the issue is probably caused by the server-image that is used over at digitalocean. Also, the version is pretty important 18.04 ? 20.10 ? 21.04? Sep 29 '21 at 0:33
2
+200

Why is Chrome not respecting the XDG configuration?

Your assessment is incorrect, Chrome does use xdg-open. The screenshot below demonstrates that both google-chrome and chromium will prompt to open "special links" with xdg-open.

prompt for xdg-open

Reset the always-run option

If you have previously accepted the "Always open files of this type" dialog, then you will need to reset this setting. The option you want to clear is this:

open certain file types automatically after downloading

To get to this option:

  1. open the special URL chrome://settings/ in chrome
  2. scroll down and click on the advanced link at the bottom
  3. Click the chevron on "andvanced" to reveal more settings
  4. there is an option under downloads that is only there if you have set at least one file to run instead of download
  5. Click on the "clear" button next to "open certain file types automatically after downloading"

There is no option to reset only some file types. You will notice that the button disappears afterwards.

Advanced settings: advanced-settings

Clear always run settings: clear-settings


Check that URL is not blocked.

Applies to Linux users who sign in to a managed account on Chrome browser. Using your preferred JSON file editor:

Go to your /etc/opt/chrome/policies/managed folder. Create or update a JSON file and enter URLs as needed: In URLBlocklist, add the URLs that you want to block. In URLAllowlist, add the URLs that you want users to access.

You can verify the currently loaded policies with: chrome://policy/

Source:


Reset the chrome protocol handler

$ grep -r ~/.config/google-chrome/ -e protocol_handler -l

If you use the default profile, then this is the file to edit:

  • $HOME/.config/google-chrome/Default/Preferences

If you are using multiple profiles, the Preferences file will be in google-chrome/Profile 2, google-chrome/Profile 3 etc.

Clear the settings for specific protocols as needed, obsidian:// in this case.

$ jq <  /home/jaroslav/.config/google-chrome/Default/Preferences  \
    | grep protocol_handler -C 2

  "custom_handlers": {
    "enabled": true,
    "ignored_protocol_handlers": [
      {
        "last_modified": "13276367110202441",
--
      }
    ],
    "registered_protocol_handlers": []
  },
  "custom_links": {
--
        },
        "ppapi_broker": {},
        "protocol_handler": {},
        "safe_browsing_url_check_data": {},
        "sensors": {},

On more recent versions of chrome, you can control this via the web-ui. Just open this special URL

  • chrome://settings/content/fileHandlers
  • chrome://settings/handlers

You want to select this:

Web apps can ask to open types of files

And

Sites can ask to handle protocols


references:

2
  • Thanks, but all of these solutions suggest that Chrome somehow got configured incorrectly at one point. But I'm running the above steps on a freshly installed machine, so I'm running this immediately after installing Chrome. Sep 27 '21 at 17:22
  • This is the only answer, and I do really appreciate the effort here - so I give you the bounty. Thank you! Sep 28 '21 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.