Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register for zotero:// and MIME types on Linux #81

Closed
dstillman opened this issue Aug 4, 2020 · 12 comments
Closed

Register for zotero:// and MIME types on Linux #81

dstillman opened this issue Aug 4, 2020 · 12 comments

Comments

@dstillman
Copy link
Member

@retorquere, have you found that the MimeType line in your version of the desktop file actually does anything? I'm trying a desktop file with that in it, but I'm having trouble finding a context where it makes a difference.

Related: #41 (comment)

@retorquere
Copy link

It does (just tried again on a clean install of Ubuntu 20.04). It looks like the apt tools invoke xdg-mime default in some way.

@dstillman
Copy link
Member Author

Oh, so is it only on an apt install? The presence of the zotero.desktop file with that line in ~/.local/share/applications won't do it?

I'm basically asking if there's any reason to add this line to the stock desktop file in the tarball.

@retorquere
Copy link

retorquere commented Aug 4, 2020

Turns out no; as long as the desktop file is in either /usr/share/applications or ~/.local/share/applications, xdg will find it. My debs were just putting them in /usr/shar/applications. Zotero has an install script that patches the desktop file, right? Might want to ln it to ~/.local/share/applications; ln will work (just tested).

edit: in which case the line in zotero.desktop does actually help:

$ xdg-mime query default x-scheme-handler/zotero
zotero.desktop

which works for any of the other mimetypes registered in de desktop file.

@dstillman
Copy link
Member Author

dstillman commented Aug 4, 2020

I'm saying that I added your MimeType line to the official zotero.desktop, did a normal ln -s into ~/.local/share/applications as per our official instructions, and I couldn't find a context where that did anything with the MimeType line.

What are you suggesting I do differently? How are you testing whether it works?

@dstillman
Copy link
Member Author

dstillman commented Aug 4, 2020

xdg-mime query default x-scheme-handler/zotero shows zotero.desktop for me, so I guess it's doing something, but a zotero://select link in Firefox (at least from a file:// URL) doesn't work, nor is Zotero offered when I go to Open With Other Application for a RIS file. So in what way is this doing something for you?

@retorquere
Copy link

I've been testing on a clean VM but apparently kept state between two tests. You're right -- after putting the desktop file in ~/.local/share/applications you still need to run xdg-mime default zotero.desktop x-scheme-handler/zotero for urls to work in FF. And it does look like the apt installation process does that for the mimetypes listed in the desktop file automatically.

@retorquere
Copy link

Except for file extensions it still does not work; looks like ris eg is not known by default.

@inukshuk
Copy link
Member

inukshuk commented Aug 5, 2020

In my experience, you need to run update-desktop-database after installing a new desktop file. This updates the cache database containing the list of MIME types handled by desktop files. If you use desktop-file-install to install the file you can also use the --rebuild-mime-info-cache option, but you may have to run update-desktop-database regardless.

I would assume that running xdg-mime default is something a user would do if there were multiple different applications handling the same type and that it should not be necessary if Zotero is the only application registered for the URL scheme.

To register unknown MIME types you can use xdg-mime install with a short XML file describing the type. Or copy the files yourself, e.g., to ~/.local/share/mime and update-mime-database afterwards. I think if your desktop file references the new MIME types you need to do this before update-desktop-database.

@retorquere
Copy link

Yeah looks like it, means I have to re-add the postinst script.

@karlicoss
Copy link

Hi, anyone knows if this functionality is working? Also is there any doc on how it was meant to work -- couldn't find anything, except some references to zotero:// in the source code.

./zotero-bin --help doesn't show -url flag. Also, not sure if it was meant to be --url?

Exec=bash -c "$(dirname $(realpath $(echo %k | sed -e 's/^file:\/\///')))/zotero -url %U"

Either way, it doesn't really work -- grepped in the code for some examples of zotero:// URLS, like zotero://debug, but when I run ./zotero-bin --url zotero://debug, nothing happens? Or am I doing something wrong?

I'm using Zotero Beta, in case it matters.

@baodrate
Copy link

@karlicoss this blog post describes some context that might be useful

@wshanks
Copy link

wshanks commented Oct 27, 2021

I played around with x-scheme-handler/zotero in the context of wshanks/Zutilo#207 (opening zotero:// item links) and found that it did make a difference, so I would recommend adding it to zotero.desktop in this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants