8 August 2012
launchctl
.Whether it is meant for work or home, DropBox provides a wide-range of clients in order to synchronize your documents. Up to now, they have not allowed multiple accounts to be easily accessed one single client. This article explains how to set up multiple DropBox accounts on OSX without rewiring your entire system and blending in with the OSX philosophy.
The procedure involves creating two different plist files which are usually used by OSX to launch applications. In this case, we are going to start the DropBox application twice by using two such plist files, each configured for a different account. The trick is to fool DropBox into believing that the home directory is placed in a different location. Not only that, but we will be using dotfiles in order to hide the DropBox folders.
The first step is to download DropBox and DO NOT set it up. If you have DropBox set-up already, make sure your files are synced and uninstall it. You can use the DropBox page to sign-up and create two accounts.
We will call the two accounts bob and alice for the remainder of the steps and assume that your username is eve.
We now create a plist file under:
~/Library/LaunchAgents
the tilde (~) in front is a shortcut for the home folder of the current user. We place the plist files there because we want to launch DropBox just for the current user and use two different DropBox accounts.
Create a plist ~/Library/LaunchAgents/org.grimore.dropbox.multibox
containing:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.grimore.dropbox.multibox</string> <key>ProgramArguments</key> <array> <string>/usr/libexec/multibox</string> <string>alice</string> <string>bob</string> </array> <key>KeepAlive</key> <true/> <key>RunAtLoad</key> <true/> </dict> </plist>
Note that you will have to change the path to your user's directory. In this case we have used:
/Users/eve/
since the article assumes that eve
is the your short username. You will have to change that to your username.
Next, we load the plist using launchctl
:
launchctl load -w org.grimore.dropbox.multibox
Before adding an account, you will have to unload the plist
:
launchctl unload ~/Library/LaunchAgents/org.grimore.dropbox.multibox.plist
Then, you can add as many accounts as you like as long as you give them an identifier:
<key>ProgramArguments</key> <array> <string>/usr/libexec/multibox</string> <string>alice</string> <string>bob</string> </array>
As you can see we have <string>alice</string>
and <string>bob</string>
. You can add another user following the same pattern: <string>bio</string>
:
<key>ProgramArguments</key> <array> <string>/usr/libexec/multibox</string> <string>alice</string> <string>bob</string> <string>bio</string> </array>
Next, we add the bash
script that will manage all the dropbox accounts by creating the file /usr/libexec/multibox
with the following contents:
#!/bin/sh ########################################################################### ## Copyright (C) Wizardry and Steamworks 2012 - License: GNU GPLv3 ## ## Please see: http://www.gnu.org/licenses/gpl.html for legal details, ## ## rights of fair usage, the disclaimer and warranty conditions. ## ########################################################################### REAL_USER=`whoami` # Sanity check. for arg in "$@"; do if [ -z "$arg" ]; then exit 1 fi done # Start DropBox instances. for arg in "$@"; do if [ -z "$arg" ]; then exit 1 fi cat > "/tmp/dropbox-$arg" <<EOF export HOME=/Users/$REAL_USER/.dropbox-$arg if [ ! -d $HOME ]; then mkdir -p $HOME fi /Applications/Dropbox.app/Contents/MacOS/Dropbox EOF /bin/sh "/tmp/dropbox-$arg" & # clean up, when loaded PID=`ps ax | grep [d]ropbox-$arg | awk '{ print $1 }'` while [ -z "$PID" ]; do sleep 1 PID=`ps ax | grep [d]ropbox-$arg | awk '{ print $1 }'` done rm "/tmp/dropbox-$arg" done # clog launchctl wait
This script loads all the users you have added to the plist
and launches dropbox so that it does not complain about other instances of itself.
You will have to make it executable by running:
chmod +x /usr/libexec/multibox
DropBox creates a sidebar icon pointing to your DropBox folder. In this case, since we have two different accounts, it will become confusing which one's which. DropBox does not make that job easy, renaming the folder will make the DropBox instances believe that the folder has been moved and even an alias will not solve the problem because the sidebar will point to the original directory.
A compromise that we have found works well is navigate to:
/Users/eve/.dropbox-alice
respectively,
/Users/eve/.dropbox-bob
by using Go… in the Finder options and then use some software like Candybar to replace the icon of the folder. This will still not work when you drag the folder to the sidebar, so instead of dragging it to the sidebar, drag it above to the Finder toolbar.
For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.