scripts reorganize

This commit is contained in:
2026-10-06 22:34:05 +02:00
parent a2a056a68d
commit 0734bee219
60 changed files with 824 additions and 5 deletions

36
scripts/WMScripts/tess.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# This script allows the user to make a selection, then runs that selection through OCR and copies the result to clipboard
case "$XDG_SESSION_TYPE" in
"wayland")
copy="wl-copy"
screenshot="grim -g"
slop=$(slurp -f "%x,%y %wx%h") || exit 1
;;
"x11")
copy="xclip -selection c"
screenshot="import -window root -crop "
slop=$(slop -f "%G") || exit 1
;;
*)
dunstify -t 2000 -u low -i ~/.icons/candy-icons/apps/scalable/code.svg "Current session type not supported by tess.sh"
exit
;;
esac
# files
imagefile="/tmp/tesseract.$RANDOM.png"
text="/tmp/translation"
# get screenshot
read -r G <<< "$slop"
bash -c "$screenshot \"$G\" $imagefile"
# OCR, save to clipboard
tesseract $imagefile $text 2>/dev/null
cat "$text.txt" | bash -c "$copy"
# cleanup
rm $text".txt"
rm "$imagefile"