Allow inkdrop:// scheme handler on Linux (Ubuntu)

Hi,

Just wanted to suggest a fix to allow Ubuntu to handle inkdrop:// uris properly.

Issue

Currently, when running

xdg-open inkdrop://<note-id>

An error message appears. (Same when entering the URI into e.g. Firefox)
The expected behaviour is that inkdrop starts and opens the requested note.

Solution

To achieve this one needs to add following line into the inkdrop.desktop file:

MimeType=x-scheme-handler/inkdrop;

and then register this under ~/.config/mimeapps.list by adding

x-scheme-handler/inkdrop=inkdrop.desktop;

This is the manual approach I used (and it works).
I don’t know what the best pratices are for apps however. As in, if they have to directly write into the mimeapps.list file or if the desktop environment offers an easy registration method.

For the snap package it should work the same way but potentially x-scheme-handler/inkdrop=inkdrop.desktop has to get changed slightly for the snap to work, depending how .desktop-files are handled there.

Happy to help/figure out the best practice if needed, just didn’t get to it yet.

Cheers,

Andi

1 Like

Hi andi,

Thank you for the suggestion and the workaround.
I didn’t know it’s possible by editing .desktop and mimeapps.list!
Could you look into our snapcraft to consider if it’s possible to support without manually editing them?

Thanks again for your help!

Looking at the snapcraft.yaml config I could not find a way to register it in there yet.
Unfortunately the .desktop files are not parsed automatically at the moment.

Mailspring (an email client that is distributed via snap too) uses xdg-mime to register itself.
They create a DefaultClientHelper classes for Mac, Windows and Linux which facilitates xdg-mime: default-client-helper.ts#L96
And then register the mailspring scheme handler during startup if required: application.ts#L145

This should work with the deb-version of inkdrop and might work with the snap verison as well (you use the home-plug in the snapcraft.yaml which means xdg-mime should have access the user’s home dir to modify the required files) If this does not work with the inkdrop snap then things become a bit more complicated (Mailspring e.g. has a separate startup script in which they compile the mime-cache and so on). In that case I would suggest to just leave it as is and wait for snap to properly integrate it.

You could add following terminal command to the documentation so linux users can add the handler themselves if they want to:

xdg-mime default inkdrop.desktop x-scheme-handler/inkdrop

Thanks a lot for the investigation.
Mailspring’s approach would work well. Since its license is GPL, I’ll plan to implement it myself without copying the source.

I think I found a simpler solution. The deb package is built using electron-installer-debian and it supports mimeType option which helps specify MimeType in .desktop file.
electron-installer-redhat also supports it.
It will hopefully work with the snap version as well.

I’ll give it a try!

It is landed in v5.0.0 :tada: