Skip to content

Instantly share code, notes, and snippets.

@hamptonmoore
Created February 16, 2020 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamptonmoore/acdac0afb9f27cc9ba0865ded09e1cdc to your computer and use it in GitHub Desktop.
Save hamptonmoore/acdac0afb9f27cc9ba0865ded09e1cdc to your computer and use it in GitHub Desktop.
LARBS maimpick but with imgur as an destination
#!/usr/bin/env sh
# This is bound to Shift+PrintScreen by default, requires maim. It lets you
# choose the kind of screenshot to take, including copying the image or even
# highlighting an area to copy. scrotcucks on suicidewatch right now.
PHOTOPATH=~/Pictures/$(date '+%y%m%d-%H%M-%S').png
upload(){
curl -s -H "Authorization: Client-ID c9a6efb3d7932fd" -H "Expect: " -F "image=$1" https://api.imgur.com/3/image.xml | sed -n 's:.*<link>\(.*\)</link>.*:\1:p' | xclip -selection clipboard
notify-send "Link has been copied to your clipboard"
}
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)\\na selected area (imgur)\\ncurrent window (imgur)\\nfull screen (imgur)" | dmenu -l 9 -i -p "Screenshot which area?")" in
"a selected area") maim -s "$PHOTOPATH" ;;
"current window") maim -i "$(xdotool getactivewindow)" "$PHOTOPATH" ;;
"full screen") maim "$PHOTOPATH" ;;
"a selected area (copy)") maim -s | xclip -selection clipboard -t image/png ;;
"current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;;
"full screen (copy)") maim | xclip -selection clipboard -t image/png ;;
"a selected area (imgur)") maim -s "$PHOTOPATH" && upload "@$PHOTOPATH" ;;
"current window (imgur)") maim -i "$(xdotool getactivewindow)" "$PHOTOPATH" && upload "@$PHOTOPATH" ;;
"full screen (imgur)") maim "$PHOTOPATH" && upload "@$PHOTOPATH" ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment