dotfiles

Torpy's handcrafted dootfiles.
Log | Files | Refs | README

maimpick (1168B)


      1 #!/bin/sh
      2 
      3 # This is bound to Shift+PrintScreen by default, requires maim. It lets you
      4 # choose the kind of screenshot to take, including copying the image or even
      5 # highlighting an area to copy. scrotcucks on suicidewatch right now.
      6 
      7 # variables
      8 output="$(date '+%y%m%d-%H%M-%S').png"
      9 xclip_cmd="xclip -sel clip -t image/png"
     10 ocr_cmd="xclip -sel clip"
     11 
     12 case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)\\ncopy selected image to text" | dmenu -l 7 -i -p "Screenshot which area?")" in
     13     "a selected area") maim -u -s pic-selected-"${output}" ;;
     14     "current window") maim -B -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;;
     15     "full screen") maim -q -d 0.2 pic-full-"${output}" ;;
     16     "a selected area (copy)") maim -u -s | ${xclip_cmd} ;;
     17     "current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;;
     18     "full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;;
     19     "copy selected image to text") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && maim -u -s > "$tmpfile" && tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;;
     20 esac