Skip to content

Instantly share code, notes, and snippets.

@tsutsu
Created January 27, 2014 05:34
Show Gist options
  • Save tsutsu/8643699 to your computer and use it in GitHub Desktop.
Save tsutsu/8643699 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'fileutils'
require 'pathname'
require 'shellwords'
call_args = ARGV.join(' ')
desktop_dir = Pathname.new(ENV['HOME']) + 'Desktop'
Dir.chdir(desktop_dir.to_s) do
image = desktop_dir + (`scrot #{ call_args } -e 'echo $f'`.chomp)
url = `imgur upload #{ Shellwords.escape( image.to_s ) }`.split("\n").map{ |ln| ln.split(': ') }.find{ |(k,v)| k == 'original' }[1]
system("play -q /usr/share/sounds/freedesktop/stereo/screen-capture.oga &")
system("echo #{ Shellwords.escape( url ) } | xclip -selection clipboard")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment