Deprecated: Return type of I::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 62

Deprecated: Return type of I::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 91

Deprecated: Return type of I::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 71

Deprecated: Return type of I::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 101

Deprecated: Return type of I::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/i.php on line 53

Deprecated: Return type of Collection::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/public/kirby/toolkit/lib/collection.php on line 80

Deprecated: parse_str(): Passing null to parameter #1 ($string) of type string is deprecated in /home/public/kirby/toolkit/lib/url.php on line 135
One Tap Less | Using Dropbox as a synced clipboard for text snippets

Using Dropbox as a synced clipboard for text snippets


Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/public/kirby/toolkit/lib/str.php on line 506

It’s hard to keep your clipboard synced between devices these days. There are only a few apps able to do this properly and even those have their misdemeanors. I couldn’t stand Paster Plus for more than a few minutes and I heard that CloudClipboard also falls short on a few features. The best clipboard manager available is Pastebot and it hasn’t been updated in ages.

Most of my articles are written on the Mac, however, most of the content comes from the iPhone, therefore, having a quick method to send actions from one device to the other is essential to speed up my workflow. On App.net, @kleerkoat and I discussed about a way to get synced snippets between devices, the trick is that he is on Windows, so none of the aforementioned apps were useful. So I created a simple workflow using Launch Center Pro and Drafts to solve this problem.

The first step was creating a file named clipboard.txt at the root folder of my Dropbox. This whole scheme would be useless if I didn’t have a way to quickly include new text to this file. A tiny Drafts action fixes that, prepending the string to the same clipboard.txt file whenever I have something to sync.

Now we need to grab the top line of text from this Dropbox text file and copy it to the clipboard. We gonna use a LCP action to grab the text and send to Drafts:

Copy Synced Clipboard:

drafts://x-callback-url/create?text=[dropbox-text:clipboard.txt]&action={{Sync Clipboard}}

This action will grab the whole content of our clipboard.txt, place it on a new Drafts document and call an action named Sync Clipboard, which looks like this:

Sync Clipboard:

drafts://x-callback-url/create?text=[[title]]&action={{Copy to Clipboard}}

It creates a new draft using only the first line of clipboard.txt and calls the built-in Copy to Clipboard action. If your text has more than a single line, this action will only place the first paragraph on the clipboard. The coolest thing about this is that I can quickly pick my shared snippets using Launchbar. Also, you can still use x-callback-url to take the action further, for example, you can move to the text editor you’re using at the moment, like Byword or 1Writer.

For those in need to sync multiple lines, we gotta appeal to Pythonista. Since we can’t rely on line breaks to separate our items, we gotta change our prepend to synced clipboard action from Drafts to create a divider between each clip. For this action, which you can download here, I’ll use double em dashes (——), but you can generate a random string on 1Password and use it, doesn’t matter. Grabbing the first item from your clipboard files also requires a new LCP action, calling for our upcoming Pythonista script.

Sync Clipboard:

pythonista://SyncClipboard?action=run&argv=[dropbox-text:clipboard.txt]

That’s really straightforward, so as our Pythonista script, which I call SyncClipboard.

# -*- coding: utf-8 -*-
import clipboard

board = sys.argv[1].split('——')

clipboard.set(board[0])

So short I wrote the code in an extra line just to make it look like it was more complicated. This script will only add the first item to the clipboard, you can also import the urllib and webbrowser modules to call for another action as we have done on many python scripts before. Happy copy-pasting.