Closed jasonccox closed 2 years ago
Thanks for your contribution! However, it doesn't work for me: Zotero was manually installed on Ubuntu Linux 22.04. Maybe I did something wrong...
Hm, I'm on Pop!_OS 22.04, which is based on Ubuntu, so that should be pretty similar. I did install Zotero via Flatpak, though, which is probably where the differences arises.
The most likely culprit I can think of is that xdg-open
doesn't know that Zotero should handle zotero://
links. If you run xdg-mime query default x-scheme-handler/zotero
, what does it output? If it outputs nothing, you can run xdg-mime default zotero.desktop x-scheme-handler/zotero
(assuming your installation created the .desktop
file as zotero.desktop
) and try again.
If that works, I'm happy to update the docs with instructions. If not, we'll have some more debugging to do.
xdg-mime query default x-scheme-handler/zotero
outputs zotero.desktop
but it still doesn't work. Also, there is no error message because the system call includes &
at the end. However, on Linux xdg-open
returns immediately. So, we don't need the ampersand and, consequently, we can capture the output and print it if there is an error. Example:
function zotcite#OpenAttachment()
let zotkey = zotcite#GetCitationKey()
let fpath = zotcite#GetPDFPath(zotkey, g:zotcite_open_in_zotero)
if fpath != ''
let cmd = s:open_cmd . ' "' . fpath . '"'
let out = system(cmd)
if v:shell_error != 0
call zotcite#warning('Error running `' . cmd . '`: ' . substitute(out, "\n", " ", "g"))
endif
endif
endfunction
Your code works if I run xdg-mime default zotero.desktop x-scheme-handler/zotero
as you suggested. So, it would be good to include the instructions in the documentation.
Okay, I've updated the docs.
Thanks!
This behavior is off by default and enabled by setting the vim variable
g:zotcite_open_in_zotero
to1
.