Skip to content

Instantly share code, notes, and snippets.

@kamranrad1993
Created October 26, 2025 09:49
Show Gist options
  • Select an option

  • Save kamranrad1993/b1836072386a471546370c67d8c376c3 to your computer and use it in GitHub Desktop.

Select an option

Save kamranrad1993/b1836072386a471546370c67d8c376c3 to your computer and use it in GitHub Desktop.
screen ocr that supports ubuntu 24.04 wayland
!/bin/bash
# Dependencies: tesseract-ocr imagemagick scrot gnome-screenshot wl-clipboard
select tesseract_lang in eng rus equ ;do break;done
# Quick language menu, add more if you need other languages.
SCR_IMG=`mktemp`
trap "rm $SCR_IMG*" EXIT
#grim -g "$(slurp)" -o $SCR_IMG.png -q 100
gnome-screenshot -a -f $SCR_IMG.png
#scrot -s $SCR_IMG.png -q 100
# increase quality with option -q from default 75 to 100
# Typo "$SCR_IMG.png000" does not continue with same name.
mogrify -modulate 100,0 -resize 400% $SCR_IMG.png
#should increase detection rate
tesseract $SCR_IMG.png $SCR_IMG &> /dev/null
cat $SCR_IMG.txt
cat $SCR_IMG.txt | wl-copy
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment