Skip to content

Instantly share code, notes, and snippets.

@dhornbein dhornbein/
Last active May 15, 2016

What would you like to do?
Bash script that captures a screenshot, saves screenshot, optionally uploads it to, and injects URL to clipboard and meta data of saved file.
# By Drew Hornbein @
# Modified from:
# By Sirupsen @
# Description: Very simple script to make you
# select a region of your screen, which will be captured, saved, and
# then uploaded. The URL will then be injected into your clipboard.
# Dependencies:
# Imgur Bash Upload Script (
# Comment: Must be in path (see below) with the name "imgur" (not
# 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:
# 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" | grep -E -o "<original_image>(.)*</original_image>" | grep -E -o "[^<]*"
name="`date "+%F_%R:%S"`_`hostname`_ss.png"
scrot -s $path$name
if [ $OUT -eq 0 ]
# asks if you want to upload
if zenity --window-icon=$path$name --title="Screenshot grabbed" --question --text="Upload $name to Imgur?"; then
url=$(uploadImage $path$name)
echo $url | xclip -selection c
notify-send -i $path$name "Image saved & Imgur link in clipboard" "Url: $url \n $path$name"
convert $path$name -set Imgur "$url" $path$name #adds the Imgru url to the file's metadata
echo $path$name | xclip -selection c
notify-send -i $path$name "$name saved: path in clipboard" "$path$name"
notify-send "Screenshot failed"

This comment has been minimized.

Copy link

M-om12om commented May 15, 2016


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.