Opening with -P -datadir profile on macos

edited April 12, 2019
Under Linux, I could add command line options to zotero to the desktop file, but how do I make zotero store data in the profile by default and always start up with the profile picker under macos when I click on the icon?
  • Don't know about -datadir, but for the profile picker, that has a checkbox to always show on startup, so if you start from terminal once, you can select that and it'll come up each time.
  • You can create a shell script like this:

    #!/bin/bash
    open -a /Applications/Zotero.app --args -p Foo


    (If you don't have multiple Zotero apps in Applications, just "-a Zotero" would suffice.)

    Then assign the Zotero icon to it and double-click that to run it. A terminal window will pop up briefly when you double-click it, but then it will close (though Terminal itself will stay open — there might be a way around that with osascript but I don't know off-hand).

    Of course, if you're developing something, you'd want a terminal window open anyway, in which case you would want to start from the command line (or use a shell script that called /Applications/Zotero.app/Contents/MacOS/zotero directly, which would keep it open until Zotero closed).
  • edited April 15, 2019
    Assigning the icon means I have two Zotero icons open -- it gets confusing which does which.

    I don't generally want the terminal window open, when I'm debugging I have output redirected and zotero is indeed launched from a script. In the end, this did it for me, ran once after install, and probably after upgrades:
    #!/usr/bin/env python3

    import plistlib
    import os

    root = '/Applications/Zotero.app/Contents'
    launcher = root + '/MacOS/zotero-p-datadir'
    zotero = root + '/MacOS/zotero'
    info = root + '/Info.plist'

    with open(launcher, 'w') as f:
    f.write('#!/bin/bash\n')
    f.write('set -x\n')
    f.write(f'{zotero} -P -datadir profile\n')

    os.chmod(launcher, os.stat(zotero).st_mode)

    with open(info, 'rb') as f:
    plist = plistlib.load(f)
    plist['CFBundleExecutable'] = os.path.basename(launcher)
    with open(info, 'wb') as f:
    plistlib.dump(plist, f)
    I've also created a plain-text file with a note to myself in ~/Zotero to prevent accidental creation of a data directory in the default location (which I might accidentally clobber); it will also alert me that I have to re-run the plist patcher after upgrades.
  • While you can do that, note that modifying the package breaks some security checks. E.g., if you use Little Snitch, it won't be able to detect that the executable was modified based on the signature. I'm not sure macOS itself checks the signature after the initial Gatekeeper check, but it might in the future.
  • edited April 15, 2019
    That all seems sensible -- I'll just deal with that when it happens (I'm not sure how long my stint with MacOS may last). I wouldn't mind if it was an extra checkbox in the profile picker popup :) but I'm well aware it's a niche issue.
  • Another option would be to patch chrome/content/zotero/xpcom/dataDirectory.js . But that would have similar concerns, right?
Sign In or Register to comment.