Created
September 20, 2010 19:17
-
-
Save mfilej/588475 to your computer and use it in GitHub Desktop.
Move the newest screen grab (png file) from the desktop to Dropbox (LaunchBar action)
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
#! /usr/bin/ruby | |
require "pathname" | |
require "fileutils" | |
require "uri" | |
def large_type(string) | |
msg = URI.encode(string) | |
system "open x-launchbar:large-type?string=#{msg}" | |
end | |
SRC_DIR = File.expand_path "~/Desktop" | |
DST_DIR = Pathname.new "~/Dropbox/Public/pic" | |
PUBLISH = "http://dl.dropbox.com/u/4381416/pic" | |
dst_name = Time.now.to_i.to_s(16).concat(".png") | |
Dir.chdir SRC_DIR do | |
pngs = Dir.glob("*.png").sort_by { |file| File.ctime(file) } | |
if pngs.empty? | |
large_type("No grabs available") | |
else | |
FileUtils.mv pngs.last, DST_DIR.join(dst_name).expand_path | |
IO.popen("pbpaste", "w") { |cb| cb << "#{PUBLISH}/#{dst_name}" } | |
large_type("Pushed URL to clipboard") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment