summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-10-02 10:30:14 +0530
committerkrolxon <krolyxon@tutanota.com>2024-10-02 10:30:14 +0530
commitde8eee3199472339edd26b41b061abc9674d22e0 (patch)
tree1b71c2bb75279a28589ab8b9bf8f2226e8470c93 /.local
parent6eebe8450018de429bf8831fc706c9bffa3d7e3f (diff)
add OCR feature to maimshot
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/maimshot5
1 files changed, 4 insertions, 1 deletions
diff --git a/.local/bin/maimshot b/.local/bin/maimshot
index c85e1c0..39d6319 100755
--- a/.local/bin/maimshot
+++ b/.local/bin/maimshot
@@ -1,10 +1,13 @@
#!/bin/sh
-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
+ocr_cmd="xclip -sel clip"
+
+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
"a selected area (copy)") maim -u -s | xclip -selection clipboard -t image/png ;;
"current window (copy)") maim -i "$(xdotool getactivewindow)" | xclip -selection clipboard -t image/png ;;
"full screen (copy)") sleep 0.2 ; maim | xclip -selection clipboard -t image/png ;;
"a selected area") maim -u -s ~/pix/ss/pic-selected-$(uuidgen | awk -F- '{printf $2}')-"$(date '+%y-%m-%d').png" ;;
"current window") maim -i "$(xdotool getactivewindow)" ~/pix/ss/pic-window-"$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;;
"full screen") sleep 0.2 ; maim ~/pix/ss/pic-full-"$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;;
+ "a selected area (OCR)") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && maim -u -s > "$tmpfile" && tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;;
esac