Created
March 3, 2013 14:59
-
-
Save mfilej/5076412 to your computer and use it in GitHub Desktop.
A ruby script that allows you to take a screenshot and pushes it to dropbox. Use <space> when grabbing to switch between window and area modes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROPBOX_DIR = "~/Dropbox/Public/pic" | |
DROPBOX_URL = "https://dl.dropbox.com/u/4381416/pic/" | |
filename = Time.now.strftime "grab-%Y%m%d-%H%M%S%4N.png" | |
target = File.expand_path File.join(DROPBOX_DIR, filename) | |
public_url = DROPBOX_URL + filename | |
abort "File already exists" if File.exists?(target) | |
def screencapture(target) | |
system "screencapture", "-i", target | |
abort "Aborted" unless File.exists?(target) | |
end | |
def clipboard_copy(text) | |
IO.popen "pbcopy", "w" do |pipe| | |
pipe.puts text | |
end | |
end | |
def notification(text) | |
IO.popen "osascript", "w" do |pipe| | |
pipe.puts <<-EOS.gsub "\n", " " | |
tell application "LaunchBar" to | |
display in notification center with | |
title "Screengrab" subtitle "#{text}" | |
EOS | |
end | |
end | |
screencapture target | |
clipboard_copy public_url | |
notification "Success! Dropbox URL copied to clipboard." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment