summaryrefslogtreecommitdiff
path: root/.local/bin/screenshot
blob: c8f2bfbcf9ba6d509c9410653bdc8c23c5be2e04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

ocr_cmd="wl-copy"

case "$(printf "a selected area (copy)\ncurrent window (copy)\nfull screen (copy)\na selected area\ncurrent window\nfull screen\na selected area (OCR)" | rofi -dmenu -l 7 -i -p "Screenshot which area?")" in
    "a selected area (copy)") hyprshot -m region -c ;;
    "current window (copy)") hyprshot -m window -c ;;
    "full screen (copy)") hyprshot -m output -c ;;

    "a selected area") hyprshot -m region -o ~/pix/ss -f "pic-selected-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;;
    "current window") hyprshot -m window -o ~/pix/ss -f "pic-window-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;;
    "full screen") hyprshot -m output -o ~/pix/ss -f "pic-full-$(uuidgen | awk -F- '{printf $2}')-$(date '+%y-%m-%d').png" ;;

    "a selected area (OCR)") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && \
        hyprshot -m region -o "$(dirname "$tmpfile")" -f "$(basename "$tmpfile")" && \
        tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;;
esac