nsmartt

Gyazo Alternative

Jul 27th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.52 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require 'rubygems'
  3. require 'mechanize'
  4.  
  5. browser = ENV['BROWSER'] ? ENV['BROWSER'] : 'xdg-open'
  6. clipcmd = "echo -n %s | xclip -selection clipboard"
  7.  
  8. scheme = '%Y-%m-%d-%s.png'
  9. location = '~/images/'
  10.  
  11. path = `scrot -s '#{scheme}' -e 'mv $f #{location}$f; echo -n #{location}$f'`
  12. if path == "" then exit end
  13.  
  14. agent = Mechanize.new
  15. resp = agent.post("http://gyazo.com/upload.cgi", :imagedata => File.new(path, 'rb'))
  16.  
  17. system "xdg-open '#{resp.body}' >/dev/null"
  18. system "#{clipcmd % [resp.body]}"
Advertisement
Add Comment
Please, Sign In to add comment