2023-09-14 11:41:52 -07:00
|
|
|
#!/usr/bin/zsh
|
|
|
|
|
|
|
|
local resp="$(fuzzel --index -d <<'EOF'
|
|
|
|
Whole screen
|
|
|
|
Selected area
|
2023-11-15 00:25:36 -08:00
|
|
|
Copy text with OCR (English)
|
|
|
|
Copy text with OCR (Japanese)
|
2023-11-20 23:18:58 -08:00
|
|
|
Select a color from the screen
|
2023-09-14 11:41:52 -07:00
|
|
|
EOF
|
|
|
|
)"
|
|
|
|
|
2023-11-26 18:48:29 -08:00
|
|
|
local outfile="${HOME}/downloads/$(date +'screenshot-%F--%H-%M-%S.png')"
|
2023-09-14 11:41:52 -07:00
|
|
|
|
2023-11-15 00:25:36 -08:00
|
|
|
# copy_with_ocr <language>
|
|
|
|
function copy_with_ocr() {
|
|
|
|
local area="$(slurp 2>&1)"
|
|
|
|
if [[ "${area}" != 'selection cancelled' ]]; then
|
|
|
|
local text="$(grim -g "${area}" -t png /dev/fd/1 |
|
2024-06-22 14:12:19 -07:00
|
|
|
tesseract stdin stdout -l ${1})"
|
2023-11-15 00:25:36 -08:00
|
|
|
wl-copy "${text}"
|
|
|
|
notify-send -t 5000 "Coppied Text" "Coppied ${#text} characters"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-09-14 11:41:52 -07:00
|
|
|
case "${resp}" in
|
|
|
|
0)
|
|
|
|
grim "${outfile}"
|
|
|
|
;;
|
|
|
|
1)
|
|
|
|
local area="$(slurp 2>&1)"
|
|
|
|
[[ "${area}" == 'selection cancelled' ]] ||
|
|
|
|
grim -g "${area}" "${outfile}"
|
|
|
|
;;
|
2024-04-29 03:18:02 -07:00
|
|
|
2)
|
2023-11-15 00:25:36 -08:00
|
|
|
copy_with_ocr eng
|
|
|
|
;;
|
2024-04-29 03:18:02 -07:00
|
|
|
3)
|
2023-11-15 00:25:36 -08:00
|
|
|
copy_with_ocr jpn
|
|
|
|
;;
|
2024-04-29 03:18:02 -07:00
|
|
|
4)
|
2023-11-20 23:18:58 -08:00
|
|
|
local color="$(hyprpicker -f hex -n -r)"
|
|
|
|
(( ${#color} == 0 )) && exit
|
|
|
|
wl-copy "${color}"
|
|
|
|
notify-send -t 5000 "Color Selected" "${color}"
|
|
|
|
;;
|
2023-09-14 11:41:52 -07:00
|
|
|
esac
|