3 ms·
I like all the error handling, but you could skip the temp files if you just pipe it through #!/usr/bin/env bash langs=(eng ara fas chi_sim chi_tra deu
by rjzzleep 3y ago
I like all the error handling, but you could skip the temp files if you just pipe it through
#!/usr/bin/env bash
langs=(eng ara fas chi_sim chi_tra deu ell fin heb hun jpn kor nld rus tur)
lang=$(printf '%s\n' "${langs[@]}" | fuzzel -d "$@")
grim -g "$(slurp)" - | mogrify -modulate 100,0 -resize 400% png:- | tesseract -l eng+${lang} - - | wl-copy
notify-send "Text extracted"
- miduil 3y agoIf you just put `set -o errexit -o pipefail -o nounset` in the first line after the shebang your script will have proper error-handling as well. Currently if any fails, notify-send will still be triggered.
- bpfrh 3y agoThis version looks nice and short, any thoughts on prober error reporting to the end user? My version has more feedback for the user which was important because the user was somebody not familiar with linux/bash, but even my version "swallows" errors.
- rjzzleep 3y agoI added the `set pipefile...` suggested below, but I think mogrify only fails if the screenshot fails. Tesseract never fails if there is a valid input image, so realistically you only need one error message for the screenshot generation, unless you want to check whether the user misses any of the tools.