Our OS LOL is very similar to your OS LOL; it’s based on BSD instead of Linux, but Mac OS has a command line with Bash as the default shell. The only mods I would make is to use the “open” command as listed upstream for the reasons stated. The underlying Unix kernel and command line were the primary push for me to even try Mac OS LOL X. I felt right at home, but with more polished apps available to me. LOL
For those who want something more robust than a Keyboard Maestro script, it is possible to make OS X take care of this for you automatically by using a launch agent. Using this method, it doesn’t matter how you start Scrivener, and you don’t need to remember to do anything special to manage DropBox at all. Instead, OS X will notice what you are doing and take care of everything for you.
To set this up, follow these three steps:
- Paste this into a plain text file:
[code]<?xml version="1.0" encoding="UTF-8"?>
Label info.stovell.DropboxAutoStopForScrivener ProgramArguments /bin/bash -c sleep 1; runningJobs=$(launchctl list); if [[ $runningJobs == *"com.literatureandlatte.scrivener2"* && $runningJobs == *"com.getdropbox.dropbox"* ]]; then osascript -e "tell application id \"com.getdropbox.dropbox\" to quit"; touch /tmp/DropboxShouldStart_$UID; elif [[ $runningJobs != *"com.literatureandlatte.scrivener2"* && $runningJobs != *"com.getdropbox.dropbox"* && -e /tmp/DropboxShouldStart_$UID ]]; then open -b com.getdropbox.dropbox; rm /tmp/DropboxShouldStart_$UID; elif [[ $runningJobs == *"com.getdropbox.dropbox"* ]]; then rm /tmp/DropboxShouldStart_$UID; fi WatchPaths ~/Library/Caches/com.literatureandlatte.scrivener2 [/code]- Save it in
~/Library/LaunchAgents
with the nameinfo.stovell.DropboxAutoStopForScrivener.plist
- Make sure the file extension really is .plist, and not .plist.txt. (Sometimes TextEdit will add a hidden .txt file extension to plain text files.)
- Be aware that
~
stands for your user’s home folder, which means that we are storing the file inside your user’s own Library folder, not your computer’s top level Library folder. - If your Mac is running OS X version 10.7 (Lion) or above, your user Library folder is hidden by default. You will need to follow the directions here in order to get access to your Library folder.
- If there is no LaunchAgents folder in your Library folder already, simply create one and then put the file in it.
- Log out and log back in.
That’s it. From now on, DropBox will quit as soon as you start Scrivener and will start again shortly after you quit Scrivener.
A couple of notes:
- If DropBox was not running when you started Scrivener, it will not start itself automatically after you quit Scrivener.
- You can manually start DropBox while Scrivener is running if you wish—but that would defeat the whole purpose of this, now wouldn’t it?
If you change your mind, simply drag info.stovell.DropboxAutoStopForScrivener.plist to the Trash, and then log out. When you log back in, everything will be back to its default behaviour.
Excellent tip, thanks for posting that!
Glad to. I’m always happy to find ways to procrastinate… er, to help others.
Nice! Pro-sociality and procrastination going together. It does make sense, actually. Totally driven people are so absorbed by their own goals and plans that they hardly notice other people.
Thanks for this, though as stopping/starting Dropbox is a relatively heavy operation, I don’t suppose there’s any way of modifying this to simply pausing/unpausing it instead?