/imgur-screenshot

Take screenshot selection, upload to imgur. + more cool things

Primary LanguageShell

the Linux Screenshot Uploader from imgur.com/apps
(also runs on OS X)

Imgur-Screenshot

A desktop notification
Notification

  1. select area of your desktop
  2. if you want, edit the screenshot with any program (gimp, image magick, ...)
  3. the screenshot is uplaoded imgur
  4. the link is copied to clipboard
  5. if you want, open the image (URL or file) with any program (browser, image viewer)

Installation

There isn't much to do. Check the dependencies below and run.

For fast access bind the script to a key.

Enjoy!

Making a selection
Selection

Dependencies

These are often pre-installed on Linux

  • curl
  • grep
  • xclip
  • libnotify-bin (Linux only)
  • scrot (Linux only)
  • terminal-notifier (OS X only)

OS X

I will make the script automatically detect this when i'm not lazy.
Using this on OS X is really simple. You just need to make a few changes:
(scrot and libnotify-bin are not required)

  1. Remove the sleep line
  2. Replace scrot with screencapture
  3. Install terminal-notifier (via brew or whatever method you like)
  4. Replace anything with the format of notify-send -foo -baz -bar "Text1" "Text2" with terminal-notifier -title "Text1" -message "Text2"

That should be it. If you find anything else that won't work, please create a new Issue.

Config

You can find this at the beginning of the script.
Optional configurations can be commented with a leading #.

  • key

    The imgur API key. Don't change this unless you have a valid key

  • ico

    Optional. The path to the imgur favicon, download here.
    imgur favicon Will be shown as icon for notifications.

  • save

    Optional. The path to the directory where you want your images saved.

  • pre

    Optional. A prefix that will be prepended to the filename. Filenames are in the format %d.%m.%Y-%H:%M:%S.png.

  • edit

    Optional. An executable that is run before the image is uploaded.
    %img is replaced with the image's filename.

  • connect

    Maximum time in seconds until the connection to imgur should be established.

  • max

    Maximum time the whole upload may take.

  • retry

    Amount of retries when the upload failed.

  • open

    Optional. An executable that is run after the image was uploaded.
    %img is replaced with the image's filename.
    %url is replaced with the image's URL.

  • log

    The path to the logfile.
    The logfile contains filenames, URLs and errors.

key="486690f872c678126a2c09a9e196ce1b"
ico="$HOME/Pictures/imgur.png"
pre="imgur-"
save="$HOME/Pictures/"
#edit="gimp %img"
connect="5"
max="120"
retry="1"
open="firefox %url"
log="$HOME/.imgur-screenshot.log"

Note

On Linux, the screenshot will be taken after the selection has been made. This could be annoying if you want to capture something quickly and then want to select an area. I might implement this as a FutureFeatureā„¢ when I find a decent way to display an image in full screen.

Troubleshooting

If you get a notification like

Something went wrong :(
Information logged to /foo/bar/logfile.log

This means that scrot -s/screencapture -s was unable to make a selective screenshot.

  • Linux: You pressed the any key during selection
  • Linux: sleep 0.1 in the script didn't help. Try increasing
  • You don't have permission to write the file
  • One of the dependencies is not installed
  • You don't have your display plugged in >_<
  • ?? - run scrot -s/screencapture -s directly and check the outcome