a.t.
a.t.

Reputation: 2779

Adding an addon to Zotero using bash?

While trying to install and configure Zotero using a bash script, I'm encountering some difficulties in adding an .xpi addon using bash. The documentation says:

To install a plugin in Zotero, download its .xpi file to your computer. Then, in Zotero, click “Tools → Add-Ons”, then drag the .xpi for the plugin onto the Add-Ons window that opens.

My closest approach was simulating the "open with" option and chosing "Zotero". However, even when using "open with" manually, Zotero assumes the incoming file is a literature file instead of an addon file. So the implementation:

#!/bin/bash
zotero some.xpi

Analogous to option 1 of this answer, launches Zotero, yet it does not (prompt the user to) install the add-on.

I did not yet find an API or method to load the add-on automatically. Hence I would like to ask: How can I add an arbitrary .xpi add-on for Zotero from a bash script?

Upvotes: 0

Views: 308

Answers (1)

a.t.
a.t.

Reputation: 2779

The instructions in the documentation did not work for me, so I found out another method:

One can

  1. Download the Zotero standalone version
  2. Get the add-on source code
  3. Compile the add-on into a build directory that contains an install.rdf file
  4. Copy this build directory into the /modules/ directory of the Zotero Standalone Build repository
  5. Compile the Zotero Standalone Build repository into a build (exported to /staging/<your system architecture>/)
  6. Add the instructions to include the new addon when Zotero loads, into the /staging/<your system architecture>/defaults/prefs.js file.
  7. Start zotero using: ./zotero.
git clone --recursive https://github.com/zotero/zotero-standalone-build
...
npm run build

git clone [email protected]<your zotero extension>.git
# Switch out build file to add additional plugin
cp -r "src/build.sh" "src/submodules/zotero/zotero-standalone-build/build.sh"
..
npm build
...
staging/Zotero_linux-x86_64/zotero -purgecaches

I created a modified build.sh file for the zotero-standalone-build which adds the extensions to the prefs.js file with:

echo 'pref("extensions.something.unopkgPaths", "{}");'  >> "$APPDIR/defaults/preferences/prefs.js"
        echo 'pref("extensions.something.version", "");'  >> "$APPDIR/defaults/preferences/prefs.js"
        echo 'pref("extensions.something.installed", false);'  >> "$APPDIR/defaults/preferences/prefs.js"
        echo 'pref("extensions.something.skipInstallation", false);'  >> "$APPDIR/defaults/preferences/prefs.js"

The build command specifics depend on the addon you want to include.

Upvotes: 1

Related Questions