Skip to content

Instantly share code, notes, and snippets.

@slowkow
Last active August 1, 2024 09:21
Show Gist options
  • Save slowkow/8834315 to your computer and use it in GitHub Desktop.
Save slowkow/8834315 to your computer and use it in GitHub Desktop.
Open pdfs in Zotero with a different program than your other pdfs

I want to open pdf files with program A unless it is stored in Zotero, in which case I want to open it program B.

  1. Change the OS settings, so the default program for opening pdf files is the shell script shown below.
  2. Set Zotero preferences to store files in "zotero-data".

Below, I use playonlinux to launch Foxit Reader for my Zotero pdf files because Foxit has nice highlighting and annotation features that I like to use on scientific articles. I use evince for all other pdf files (figures, books, documents, etc.)

#!/bin/bash

# Check if the pdf is in the Zotero folder.
if [[ "$1" == */zotero-data/storage/* ]]
then
    # Replace all / with \ (needed for the windows program Foxit Reader)
    f="z:${1//\//\\}"
    /usr/share/playonlinux/playonlinux --run "Foxit Reader" "$f"
else
    evince "$1"
fi
@joelostblom
Copy link

Nifty, thanks!

@diegodlh
Copy link

Great idea

@bestucan
Copy link

It works. thanks.

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