02/25/14 19:00:27

Building a Cloud-Enabled Dropbox-Powered Clipboard

Just yesterday I was, again, frustratingly sitting on my Mac waiting for CloudClipboard to sync new content I created on my iPhone. The changes just wouldn’t show up. It’s not the fault of CloudClipboard, it is iCloud that is the culprit here.

I thought Unclutter would be a good cloud clipboard, because I could just move its content folder to Dropbox. The problem with Unclutter is, however, that it only retains one image file and only has one text file. With Keyboard Maestro on my Mac and clipboard history enabled, only having one picture is not enough.

So I decided to make my own.

Hazel, Launch Center Pro, Keyboard Maestro, Dropbox

If you are into OS X and iOS automation you are going to love this. My approach is the following.

Basically there are two kinds of content that I want to transfer. One is text, the other are images. I can accept when the text is in plain text. Or, in other words, when the formatting gets lost in the process.
I don’t want it to be automatic, e.g. putting clipboard contents in Dropbox automatically. I think across platforms it is more desirable to share specific content only, not everything.

Basic setup: create a folder in Dropbox. Mine is /Apps/Clibpoard/.

iOS

On iOS I need a thing to put stuff from the clipboard in Dropbox, and something to put stuff from Dropbox on the clipboard. Just the basic Dropbox app is good enough to put stuff that is in Dropbox, on the clipboard. Getting new content into Dropbox is not that easy.
Luckily Launch Center Pro has Dropbox now built in. It is very easy to setup a couple of actions to help us here. You can use the Composer. System ActionsIn-App DropboxUpload Photo/New File.

To get stuff from Dropbox onto the iOS clipboard, use the Copy File to Clipboard action.

OS X

My Mac has more amazing automation and is a little bit more powerful.

Hazel monitors the Clipboard folder for new files to arrive.

Text files:

If new file added → has Extension → txt
AND
Name → does not contain → mac

Execute Shell script
cat "$1" | pbcopy

Image files:

If new file added → has Extension → png/jpg
AND
Name → does not contain → mac

Execute AppleScript
try
    set the clipboard to (read (theFile as alias) as TIFF picture)
on error
    return 1
end try

Getting new stuff into the Clipboard is almost as easy. Whatever automation tool you use, I’m pretty certain you can come up with something, e.g. an Alfred Workflow. I chose Keyboard Maestro, naturally.

I tried various approaches, but the fastest, workable solution to not having double entries on the clipboard was to add a suffix (Mac) to the files.

I’m using ⌃V as shortcut, and put the macro in my Available in: Finder group.

Clipboard History

For those who want to auto-delete the clipboard history, you can add a Hazel action to remove items that are older than, say, a week or so. I personally don’t need that, but mentioning it here is possibly an inspiration for you.

Download