Easy Screenshot Sharing in OSX

Now that I’m using a Mac, the screenshot uploader I wrote isn’t all that helpful. Shame, I was really enjoying the quick and easy screenshot sharing. Fortunately, OSX has some built-in hotkeys for taking screenshots. What’s more, you can change where they save. What’s even more, you can add scripted actions to folders with Applescript. Mix in a little Dropbox, and BAM, I’m sharing screenshots with the greatest of ease!

The flow goes like this: Capture screenshot (selection, window, screen, whatever), it gets saved to my Dropbox Public folder, the link gets copied into my clipboard, and I get a Growl notification when it’s all ready to go. Here’s how.

First, change the screenshot save location:

1
2
defaults write com.apple.screencapture location ~/Dropbox/Public
killall SystemUIServer

Next, create an Applescript file to copy the URL of new files:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
on adding folder items to this_folder after receiving added_items
try
set the item_count to the number of items in the added_items
if the item_count is equal to 1 then
set theFile to item 1 of added_items
set theRawFilename to ("" & theFile)

set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set theFileName to (text item 6 of theRawFilename) as text
set AppleScript's text item delimiters to tid

set theWebSafeFileName to switchText from theFileName to "%20" instead of " "

set theURL to "http://dl.getdropbox.com/u/8469532/" & theWebSafeFileName
set the clipboard to theURL as text

tell application "GrowlHelperApp"

-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to ¬
{"Public URL"}

set the enabledNotificationsList to allNotificationsList

-- Register our script with growl.
-- You can optionally (as here) set a default icon
-- for this script's notifications.
register as application ¬
"CopyDropboxURL" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Dropbox"

notify with name ¬
"Public URL" title ¬
"Dropbox Public Folder Updated" description ¬
(theURL & " copied to clipboard.") application name "CopyDropboxURL"

end tell
end if
end try
end adding folder items to

to switchText from t to r instead of s
set d to text item delimiters
set text item delimiters to s
set t to t's text items
set text item delimiters to r
tell t to set t to item 1 & ({""} & rest)
set text item delimiters to d
t
end switchText

That’s it! Snap a screenshot (or drop a file in your Public folder, it all works the same), wait for the Growl notification, and paste away!