Using a different PDF Viewer in Standalone in Linux

Hey folks. Been working with Zotero for about a week to see if it will suffice for a research group I'm in.

I can't find a way to change my pdf readers in Zotero Standalone, and all of the forum threads I've seen on the subject are talking about the in-firefox plugin. I'm sure this is relatively easy - any help?

(adamsmith, *cough*, you've mentioned that you also use linux and the standalone)
  • Zotero uses the system's default PDF viewer. There's no easy way to change that.
  • Actually, the answer is a bit more complicated than that. Under Linux, Zotero uses the gtk defaults. If you are using KDE on OpenSuse, for example, it is not enough to modify the Desktop settings, you will have to also modify the gtk preferences for pdf viewer, which in my system are found in the file:
    /usr/share/applications/defaults.list

    the change is:
    204c204
    < application/pdf=AdobeReader.desktop
    ---
    > application/pdf=kde4-okularApplication_pdf.desktop
  • edited March 6, 2015
    Thank you Dan Stillman.

    I guess that should be the implementation for the local account. Except that it does not work on my installation of OpenSuse 13.1
    I reverted the changes above and my default went back to Acroread.
    Then I tested the following

    ~> less ~/.local/share/applications/defaults.list
    /home/mborgnia/.local/share/applications/defaults.list: No such file or directory
    ~> echo application/pdf=kde4-okularApplication_pdf.desktop >> \ ~/.local/share/applications/defaults.list
    ~> cat ~/.local/share/applications/defaults.list
    application/pdf=kde4-okularApplication_pdf.desktop

    Standalone Zotero continues to open my pdf files in Acroread

    Of course, all along
    ~> grep pdf ~/.local/share/applications/mimeapps.list
    application/pdf=kde4-okularApplication_pdf.desktop

    Reverted back the global variable as indicated above and Zotero opens Okular as expected.
    So, I will stay with my solution for now.

    As we say in Perl TMTOWTDI
  • edited September 22, 2015
    adamsmith Feb 6th 2014

    Zotero uses the system's default PDF viewer. There's no easy way to change that.


    The above is untrue. My system default PDF viewer is Okular. Any time I open a PDF, directly or from an application, it opens in Okular. The only exception is when I open a PDF from Zotero, in which case the PDF is opened in Adobe Reader. Zotero does not use my system default PDF viewer.
  • well, "system defaults" are a bit of a mess in Linux since they can be set and read from multiple places (see mborgnia's detailed answer right below mine), so it's possible to have a situation where a default double click uses one PDF viewer and Zotero another, but as a general statement of intent--and as an answer to the original question, which was about purposefully selecting different PDF viewers--what I wrote was correct.
  • Actually, to make this even more complicated, I think there are ways — which may differ on different platforms, and maybe even between different Linux systems — in which Zotero Standalone can end up storing its own file association for certain file types. I've seen a helper dialog in Standalone before, and if you tell it to remember the selection, there's no visual way to change that short of deleting mimeTypes.rdf from the profile directory. So while usually this is dependent on obscure system defaults, as adamsmith says, if you're having trouble you might also try clearing that file.
  • @Dan Stillman: At the time I installed Zotero, I did not have Okular installed. I have a suspicion that perhaps, during the Zotero install, it grabs a reference to whichever PDF viewer is the default at the time and hangs onto it (regardless of whether one later installs another PDF viewer and sets it as default). I'm not sure I want to clear the MIME-types file, but may get brave enough to give it a shot later.

    In any case, despite the inability to change the PDF viewer, I absolutely love Zotero!
  • I think that would only happen if it did in fact give you an option at one point and you told it to remember it. In any case, the mimeTypes file shouldn't have an effect on anything else in Zotero, and it will be recreated automatically when you restart Zotero, so it's safe to try that.
  • This resource says that Zotero's profile directory on Linux should be at "~/.zotero/Profiles/<randomstring>." For some reason, mine is at "~/.zotero/zotero/<randomstring>.default/."

    In any case, I closed Zotero, deleted the "mimeTypes.rdf" file and restarted Zotero, to no avail (Zotero still used Adobe Reader instead of the system default PDF viewer).

    I also repeated the above after having uninstalled/purged Adobe Reader from my system. This actually did cause Zotero to start using my system default viewer (Okular). However, I need Adobe Reader (only) for high-quality printing, as Okular's print quality is lacking. Therefore, I reinstalled Adobe Reader, and Zotero immediately went back to using it for viewing PDF files. Strangeness. :)

    In any case, I can learn to live with Zotero's use of Adobe Reader to open PDF files (or, in the alternative, may try to come up with a hack as time permits). I appreciate the explanations and suggestions, guys!
  • You can also check to see what xdg-open does from the command line. Zotero falls back to that on some systems, when it has no other alternative. If you deleted mimeTypes.rdf, Zotero is definitely not choosing Adobe Reader itself.
  • xdg-open [path-and-name-of-any-pdf] opens the file in Okular (the system default viewer).
  • To change form Acrobat reader to Evince:

    gedit ~/.local/share/applications/mimeapps.list&

    Replace AdobeReader.desktop to evince.desktop as shown below:

    [Default Applications]
    application/pdf=evince.desktop
  • Is there any reason Zotero shouldn't just use xdg-open to open PDFs?
  • edited August 9, 2016
    abhirkmv: Not sure — I don't really know enough about file opening on desktop Linux to know the situations when xdg-open differs from the "system default" (whatever exactly that means) that Mozilla's nsIFile.launch() method uses. Does xdg-open exist by default on most distros? If someone sets default programs in their desktop settings, is that what xdg-open will always pick?

    Granted, one advantage to prioritizing xdg-open would be that it would make debugging this a lot easier than digging through the morass of potentially relevant config files that can be involved now.
  • It seems that nsIFile.lanunch() is hard coded for GNOME-based Desktop Environments:
    https://bugzilla.mozilla.org/show_bug.cgi?id=694870

    I have painlessly used xdg-open and other tools of the xdg-utils suite in both GNOME and KDE.
    In both these desktop environments, xdg-open/xdg-mime is pre-configured to make the right choices, e.g. evince/nautilus on GNOME and okular/dolphin on KDE.

    Unlike xdg-open, I have no idea how to get Zotero to open PDFs on my favourite PDF reader (PDFStudio). I tried everything mentioned in this thread.
  • I guess nsIFile.launch() works on all platforms, including Windows, where xdg-open doesn't. If so, sticking to nsIFile.launch() may indeed be convenient.
    I hope that Mozilla will fix nsIFile.launch() some day to properly use Freedesktop standards on linux.
  • We can easily use a different method on Linux, so that part wouldn't be a problem if we think trying xdg-open first makes sense.
  • After removing nautilus, Zotero opens Dolphin (in KDE) when I choose "Show File". Then, unlike in Nautilus, double-clicking the PDF file in Dolphin opens in the "correct" application.
    All this may seem not surprising, but I was worried that after removing nautilus, Zotero may fail on "Show File".
  • I have tried perhaps not everything but several of the suggestions above, even if I found none of them really convincing in itself. On opensuse leap 42.2, clicking on the reference opens libreoffice and then shows the pdf there: certainly the worst conceivable solution of all.

    Just why cannot the standalone client have a simple, understandable option for ordinary people which allows to define the pdf viewer?
  • I had a similar issue running Okular with KDE Plasma 5 on Arch Linux. My Zotero insisted on opening PDFs in Gimp and, after uninstalling Gimp, in LibreOffice Draw, rather than in my configured default Okular.

    I was able to solve it by using KDE's build-in file associations manager (System settings -> Applications -> File associations). There, under application/pdf, I originally had Okular, then Gimp, then LibreOffice Draw. I removed Gimp and Draw from this list, and after that, Zotero defaulted to Okular.

    On the backend, it seems the KDE file associations program modifies the `~/.config/mimeapps.list` file. My new one looks like this (unfortunately, I didn't check what the old one looked like, but it was probably empty and deferred to the system default mimeapps.list file, wherever that is...):

    ``` ~/.config/mimeapps.list
    [Added Associations]
    application/pdf=okularApplication_pdf.desktop;

    [Default Applications]
    application/pdf=okularApplication_pdf.desktop;

    [Removed Associations]
    application/pdf=libreoffice-draw.desktop;gimp.desktop;
    ```

    It seems Zotero is doing something sensible after all, and the documentation on the website (https://www.zotero.org/support/kb/file_handling_issues#pdfs_opening_in_wrong_application_on_gnulinux_systems) is out of date. Useful information on MIME types is available, as expected, from the Arch Wiki (https://wiki.archlinux.org/index.php/default_applications#XDG_standard).

    Note that this definition for Okular (okularApplication_pdf.desktop) seems to be new to the latest version of Okular. Those of you with older versions should use whatever the appropriate `.desktop` entry is.
  • Marvelous, that last response fixed it for me. I just wonder why such things need to get so messed up in the first place.
  • I have searched this forum and tried several suggestions, including this last one, and it has no effect on how Zotero behaves on my system. Is anyone else still having problems on Linux configuring the default application? No matter what I set in preferences, or what file I associate with MIME type application/pdf, I always get a prompt from Zotero to select the application I want to use to open PDF files. When I double click on the application I want to use, it works. So, that's good. But, I am confused as to why all approaches I have tried have no effect on Zotero behavior.
  • edited March 8, 2019
    @prdpdx: This thread predates the ability to choose a PDF reader in the Zotero preferences, which is now the easiest way to fix this on Linux. Are you saying that even selecting a specific PDF reader from the preferences doesn't work? Can you provide a Debug ID for an attempt to open a PDF with that configuration?
  • Thanks for your help!

    Yes, you can take a look at this: 1009846184. However, that one includes another problem I was trying to work through, which is that Zotero does not "see" all executable files in /usr/bin. Specifically, when I select "Custom..." in the preferences, I get the file selection dialog, but when I got to /usr/bin, to select 'evince', it is not there. It is there in my file system, but Zotero cannot seem to find it. This is very strange and I don't entirely understand it, but I think it has to do with the fact that I'm using a flatpak-based app version of Zotero. I think flatpak apps are sandboxed in some way that causes this.

    1055367047 is another one with the preference just set to System Default. Less other cruft for you to wade through.

    However, I have also tried setting the preference value to /usr/bin/xdg-open, which Zotero can find, and which I can be sure gives the right behavior, since I can test it, independently. And still Zotero gives me the dialog to choose an application rather than calling xdg-open. I don't understand that, either. Seems like Zotero isn't using the preference value at all, like it doesn't understand the value and is using some fallback method, or there exists a higher precedence preference that is set to 'always ask.'
  • edited March 8, 2019
    That's a Report ID, not a Debug ID — we'd need the latter. But we can only provide support for the official tarball, so we'll need you to test with that rather than the Flatpak. I'm not really familiar with the details, but our understanding is indeed that the Flatpak sandboxing breaks various functionality in Zotero.
  • This still does not work. please for the love of god, just make zotero open in whatever xdg-open opens in
Sign In or Register to comment.