How to set a separate default PDF-viewer for Zotero

Update 2017-02-24

My current script is much simpler:


# Use a pdf-viewer with anootation capabilities if I open
# an article from my Zotero folder
if [[ "$1" == /home/joel/edu/articles/* ]]
    masterpdfeditor4 "$1"
    zathura "$1"

As you can see, I have recently switched PDF-viewer to zathura and masterpdfeditor.

Updated 2016-09-23

I prefer to use evince for opening PDFs in general, but for scientific articles opened from Zotero, I need more annotation features than evince currently provides. For this purpose, PDF-XChange, which I have installed via wine, is my preferred tool. Previously, my workflow was Right click item in Zotero » Show File » Right click file in file browser » Open with PDF-XChange. Quite cumbersome, so I can happily said that I just found out about a more seamless solution!

  • This is a nifty script that uses the fact that Zotero files are saved to a specific location, and changes PDF-viewer based on the location of the file. This is one of those “Why didn’t I think of that”-moments =) I tweaked a few things and my final script ~/tools/_misc/zotero-pdf looks like this:

# If the current folder is the zotero folder,
# the current folder path needs to be added to the file name.
if [[ "$PWD" == ~/edu/articles ]] && [["$1" ~=]]

# Check if the pdf is in the Zotero folder.
if [[ "$full_path" == ~/edu/articles/* ]]
    # Replace all / with \ (needed for windows programs opened via wine)
    wine ~/.wine/drive_c/Program\ Files\ \(x86\)/Tracker\ Software/PDF\ Editor/PDFXEdit.exe "$full_path"
    evince "full_path"
  • Make it executable, chmod +x ~/tools/_misc/zotero-pdf.
  • Create a desktop entry in ~/.local/share/applications/zotero-pdf.desktop pointing to the script.
    • Note that the absolute path must be used for Exec=. Abbreviating the home directory with ~ gave me problems, I guess I should stick to absolute paths in general in the future.
    • Desktop entries can be validated with desktop-file-validate <filename>. No output = no errors.
[Desktop Entry]
  • Add this as the new default by modifying ~/.config/mimeapps.list and changing the line application/pdf=evince.desktop to application/pdf=zotero-pdf.desktop.
    • I was a little lost here initially, mostly because I had an idea of how to do this in Ubuntu and instead of reading the Arch wiki calmly from start to finish, I jumped to the section that looked familiar based on my previous knowledge. There is a lot of info on this topic in the wiki, and it is easy to get bogged down in details. The two necessary steps are clearly listed directly under “Set default applications”, but instead I focused on trying to get mimeopen to work, which it never did.
    • This is all you need to do, you can check the default application with xdg-mime query default application/pdf which should output zotero-pdf.desktop. Likewise, “ZoteroPDF” (or whatever you named your program in the desktop file) should now show up as the default program in Nautilus “Open With” and PDF-XChange should handle all PDFs opened from Zotero.
Post-doctoral teaching fellow

Developmental biology researcher and data science educator