Skip to content

Instantly share code, notes, and snippets.

@dnordstrom
Forked from sirupsen/shoot.sh
Created August 17, 2018 22:28
Show Gist options
  • Save dnordstrom/c1cae63fffa34bb14b1ca62e49e1a480 to your computer and use it in GitHub Desktop.
Save dnordstrom/c1cae63fffa34bb14b1ca62e49e1a480 to your computer and use it in GitHub Desktop.
Simple Linux screenshot utility for Imgur.
#!/bin/bash
#
# By Sirupsen @ http://sirupsen.dk
#
# 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 inserted into your clipboard.
#
# Dependencies:
#
# Curl
# Comment: What makes us able to upload the screenshot.
#
# 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)
#
# Personally I've made Openbox activate the script once I press
# Alt-Shift-3. You might be able to do something similar in your
# environment.
#
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/[^<]*"
}
scrot -s "shot.png"
uploadImage "shot.png" | xclip -selection c && rm "shot.png"
#notify-send "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment