maimpick (1465B)
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 get_active_window() { 13 hyprctl -j activewindow | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' 14 } 15 16 case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)\\ncopy selected image to text" | wmenu -l 7 -i -p "Screenshot which area?")" in 17 "a selected area") geometry=$(slurp) && sleep 0.2 && grim -g "$geometry" pic-selected-"${output}" ;; 18 "current window") geometry=$(get_active_window) && sleep 0.2 && grim -g "$geometry" pic-window-"${output}" ;; 19 "full screen") geometry=$(slurp -o) && sleep 0.2 && grim -g "$geometry" pic-full-"${output}" ;; 20 "a selected area (copy)") geometry=$(slurp) && sleep 0.2 && grim -g "$geometry" - | ${wclip_cmd} ;; 21 "current window (copy)") geometry=$(get_active_window) && sleep 0.2 && grim -g "$geometry" - | ${wclip_cmd} ;; 22 "full screen (copy)") geometry=$(slurp -o) && sleep 0.2 && grim -g "$geometry" - | ${wclip_cmd} ;; 23 "copy selected image to text") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && slurp | grim -g - - > "$tmpfile" && tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;; 24 esac