Opening with -P -datadir profile on macos

edited April 12, 2019
188BET靠谱吗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
    188BET靠谱吗open -a /Applications/Zotero.app --args -p Foo


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

    Then 188BET靠谱吗assign the Zotero icon to itand 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).

    188BET靠谱吗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
    188BET靠谱吗Assigning the icon means I have two Zotero icons open -- it gets confusing which does which.

    188BET靠谱吗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

    188BET靠谱吗root = '/Applications/Zotero.app/Contents'
    188BET靠谱吗launcher = root + '/MacOS/zotero-p-datadir'
    188BET靠谱吗zotero = root + '/MacOS/zotero'
    info = root + '/Info.plist'

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

    188BET靠谱吗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 188BET靠谱吗~/Zoteroto 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.
  • 188BET靠谱吗Another option would be to patch chrome/content/zotero/xpcom/dataDirectory.js .But that would have similar concerns, right?
Sign Inor Registerto comment.