Page 2 of 2

Re: Small DropBox Tip

Posted: Fri Aug 02, 2013 6:38 am
by rms
Seems like something that could be easy to do with the 3rd party Mac tool called "Keyboard Maestro". I can see where it's simple to look for "Launch" or "Quit", but it probably takes an Apple script to do the next step of telling Dropbox turn on or off "Pause". I can't get my head around Apple scripts. Perhaps someone can?

Re: Small DropBox Tip

Posted: Fri Aug 02, 2013 9:39 am
by Mex5150
Hi All

Turns out the script was far easier than I though it would be:

Code: Select all

dropbox stop
scrivener
dropbox start
This works perfectly on Linux, and I don't see why it wouldn't on Windoze, I'm afraid you Mac guys are on your own thoug I know next to nothing about your OS LOL <sorry>

Anyway, to use the above just save it as a script and run that instead of starting Scrivener as you normally woud.

-Mex

Re: Small DropBox Tip

Posted: Fri Aug 02, 2013 1:20 pm
by Gordon Robb
OK, mister script guy :) I know you're stating this like it's an easy thing but...

what do you mean save this as a script and just run it? (Windows i'm talking about)

Re: Small DropBox Tip

Posted: Fri Aug 02, 2013 2:12 pm
by Niran
I was looking for something elegant in keyboard maestro to pause Dropbox. But, you can not access Dropbox menus via keyboard maestro. However, using launching and quitting Scrivener as a trigger, keyboard maestro can stop and start Dropbox.

drpsync.jpg
Quit Dropbox
drpsync.jpg (24.92 KiB) Viewed 1582 times


drpstopsync.jpg
Re-launch Dropbox
drpstopsync.jpg (21.9 KiB) Viewed 1582 times

Re: Small DropBox Tip

Posted: Fri Aug 02, 2013 2:38 pm
by Mex5150
Hi,
Gordon Robb wrote:OK, mister script guy :) I know you're stating this like it's an easy thing but...

what do you mean save this as a script and just run it? (Windows i'm talking about)

I don't have a windoze box here to try it on, but what you need to do is copy and past the above code into notepad and save it as a *.bat file. Double click it to run and is should work. If it doesn't try replacing the scrivener line with it's full path, it will probably be something like "C:Program Files/Scrivener/Scrivener.exe" If that doesn't work either give me a shout, and I'll set up a win virtual box to have a play and see if I can sort it out.

-Mex

Re: Small DropBox Tip

Posted: Fri Aug 02, 2013 4:09 pm
by robertdguthrie
Mex5150 wrote:Hi All

Turns out the script was far easier than I though it would be:

Code: Select all

dropbox stop
scrivener
dropbox start
I'm afraid you Mac guys are on your own thoug I know next to nothing about your OS LOL <sorry>


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

Re: Small DropBox Tip

Posted: Wed Aug 21, 2013 9:51 am
by jstovell
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:

  1. Paste this into a plain text file:

    Code: Select all

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
       <key>Label</key>
       <string>info.stovell.DropboxAutoStopForScrivener</string>
       <key>ProgramArguments</key>
       <array>
          <string>/bin/bash</string>
          <string>-c</string>
          <string>sleep 1; runningJobs=$(launchctl list); if [[ $runningJobs == *"com.literatureandlatte.scrivener2"* &amp;&amp; $runningJobs == *"com.getdropbox.dropbox"* ]]; then osascript -e "tell application id \"com.getdropbox.dropbox\" to quit"; touch /tmp/DropboxShouldStart_$UID; elif [[ $runningJobs != *"com.literatureandlatte.scrivener2"* &amp;&amp; $runningJobs != *"com.getdropbox.dropbox"* &amp;&amp; -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</string>
       </array>
       <key>WatchPaths</key>
       <array>
          <string>~/Library/Caches/com.literatureandlatte.scrivener2</string>
       </array>
    </dict>
    </plist>

  2. Save it in

    Code: Select all

    ~/Library/LaunchAgents
    with the name

    Code: Select all

    info.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

      Code: Select all

      ~
      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.
  3. 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:
  1. If DropBox was not running when you started Scrivener, it will not start itself automatically after you quit Scrivener.
  2. 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.

Re: Small DropBox Tip

Posted: Wed Aug 21, 2013 9:11 pm
by AmberV
Excellent tip, thanks for posting that!

Re: Small DropBox Tip

Posted: Thu Aug 22, 2013 12:05 am
by jstovell
Glad to. I'm always happy to find ways to procrastinate... er, to help others. :lol:

Re: Small DropBox Tip

Posted: Thu Aug 22, 2013 4:25 am
by marcoiac
jstovell wrote:Glad to. I'm always happy to find ways to procrastinate... er, to help others. :lol:


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.

Re: Small DropBox Tip

Posted: Sat Apr 05, 2014 8:28 pm
by kdbertel
jstovell wrote: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.


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?