vincentbernat.i3wm-configur.../bin/screenshot
2023-08-01 21:43:39 +02:00

29 lines
955 B
Bash
Executable file

#!/bin/bash
set -euf -o pipefail
case $1 in
desktop)
target=~/.config/i3/screenshots/$(date -Iseconds).jpg
maim -u -m 9 $target
notify-send -i camera-photo "Desktop screenshot" "Saved in ${target##*/}"
echo -n $target | xclip -selection clipboard
;;
window)
target=/dev/shm/screenshot.png
maim -u $target
nsxiv -N nsxiv-screenshot --anti-alias=no -b /dev/shm/screenshot.png &
nsxiv_pid=$!
maim -u -s -b 5 -l -c 0.3,0.4,0.6,0.4 -d 0.1 \
| xclip -selection clipboard -t image/png
kill "$nsxiv_pid"
# rm -f $target
notify-send -i camera-photo "Screenshot" "Saved to clipboard"
;;
ocr)
maim -u -s -b 5 -l -c 0.3,0.4,0.6,0.4 -d 0.1 \
| tesseract --dpi 96 -l eng - - \
| xclip -selection clipboard -t text/plain
notify-send -i ebook-reader "OCR" "Saved to clipboard"
;;
esac