Created
June 16, 2012 15:40
-
-
Save kynan/2941720 to your computer and use it in GitHub Desktop.
Take a screenshot and upload to imgur
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
#!/bin/bash | |
# | |
# By Sirupsen @ http://sirupsen.dk | |
# Original version: http://sirupsen.com/a-simple-imgur-bash-screenshot-utility | |
# Modifications by Florian Rathgeber @frathgeber (https://github.com/kynan) | |
# | |
# Description: Very simple script to make you | |
# select a region of your screen, which will be captured, and | |
# then uploaded. The URL will then be injected into your clipboard. | |
# | |
# Dependencies: | |
# | |
# Imgur Bash Upload Script (http://imgur.com/tools/imgurbash.sh) | |
# Comment: Must be in path (see below) with the name "imgur" (not imgur.sh) | |
# | |
# Scrot | |
# Comment: Scrot is what takes the actual screenshot. | |
# | |
# Xclip | |
# Comment: Xclip is what makes the script able to inject the direct url | |
# into your clipboard. | |
# | |
# libnotify* | |
# Comment: Will notify you whenever the direct URL is in the clipboard | |
# | |
# Installation: | |
# | |
# Move the file to a local bin. And put the path of this bin, into | |
# your path. (See: www.troubleshooters.com/linux/prepostpath.htm) | |
# | |
# From then on, you can either activate it via your terminal, or via | |
# your window manager or similar, so you can bind it to a keycombination. | |
function uploadImage { | |
curl -s -F "image=@$1" -F "key=486690f872c678126a2c09a9e196ce1b" http://imgur.com/api/upload.xml | grep -E -o "<original_image>(.)*</original_image>" | grep -E -o "http://i.imgur.com/[^<]*" | |
} | |
f=$(tempfile -d '/tmp' -s '.png') | |
scrot -s $f | |
if [ -x `which imgur` ]; then | |
imgur $f | |
else | |
uploadImage $f | xclip -selection c | |
fi | |
rm -f $f | |
notify-send "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
awesome man, thanks!