swaydots

my dotfiles
git clone https://git.awy.one/swaydots.git
Log | Files | Refs | README | LICENSE

maimpick (1319B)


      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 wclip_cmd="wl-copy -t image/png"
     10 ocr_cmd="wl-copy"
     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" | bemenu -l 7 -i -p "Screenshot which area?")" in
     13 	"a selected area") geometry=$(slurp) && sleep 0.2 && grim -g "$geometry" pic-selected-"${output}" ;;
     14 	# "current window") maim -B -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;;
     15 	"full screen") geometry=$(slurp -o) && sleep 0.2 && grim -g "$geometry" pic-full-"${output}" ;;
     16 	"a selected area (copy)") geometry=$(slurp) && sleep 0.2 && grim -g "$geometry" - | ${wclip_cmd} ;;
     17 	# "current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;;
     18 	"full screen (copy)") geometry=$(slurp -o) && sleep 0.2 && grim -g "$geometry" - | ${wclip_cmd} ;;
     19 	"copy selected image to text") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && slurp | grim -g - - > "$tmpfile" && tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;;
     20 esac