dotfiles-x11de8eee3
add OCR feature to maimshot
+4 −1
1 file changed
- M .local/bin/maimshot +4 −1
| @@ -1,10 +1,13 @@ | |||
| 1 | 1 | #!/bin/sh | |
| 2 | 2 | ||
| 3 | − | case "$(printf "a selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)\\na selected area\\ncurrent window\\nfull screen" | dmenu -l 6 -i -p "Screenshot which area?")" in | |
| 3 | + | ocr_cmd="xclip -sel clip" | |
| 4 | + | ||
| 5 | + | case "$(printf "a selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)\\na selected area\\ncurrent window\\nfull screen\\na selected area (OCR)" | dmenu -l 6 -i -p "Screenshot which area?")" in | |
| 4 | 6 | "a selected area (copy)") maim -u -s | xclip -selection clipboard -t image/png ;; | |
| 5 | 7 | "current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;; | |
| 6 | 8 | "full screen (copy)") sleep 0.2 ; maim | xclip -selection clipboard -t image/png ;; | |
| 7 | 9 | "a selected area") maim -u -s ~/pix/ss/pic-selected-$(uuidgen | awk -F- '{printf $2}')-"$(date '+%y-%m-%d').png" ;; | |
| 8 | 10 | "current window") maim -i "$(xdotool getactivewindow)" ~/pix/ss/pic-window-"$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;; | |
| 9 | 11 | "full screen") sleep 0.2 ; maim ~/pix/ss/pic-full-"$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;; | |
| 12 | + | "a selected area (OCR)") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && maim -u -s > "$tmpfile" && tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;; | |
| 10 | 13 | esac | |