pasting from my keybind config
# snippet based on end4 dotfiles -- FIXME edge case where a
# preexisting tmp.png might be overwritten
# English
bind = Super+Shift,T,exec,grim -g "$(slurp $SLURP_ARGS)" "tmp.png" && tesseract -l eng "tmp.png" - | wl-copy && rm "tmp.png"
# Korean
bind = Super+Shift,K,exec,grim -g "$(slurp $SLURP_ARGS)" "tmp.png" && tesseract -l kor "tmp.png" - | wl-copy && rm "tmp.png"
# Japanese
bind = Super+Shift,J,exec,grim -g "$(slurp $SLURP_ARGS)" "tmp.png" && tesseract -l jpn "tmp.png" - | wl-copy && rm "tmp.png"
I just pipe grim and slurp (i.e. select part of the Wayland screen then copy) into a temporary png, tesseract it into the clipboard, then delete the temporary png.
edit: clarified
edit: based on the other commenter I think I might be missing a simpler declarative way to do this. The following will be kept for posterity though
The main idea is:
hyprctl -j
which givesbut in Sway it might be something similar to using swaymsg. Only titled windows will have the bracket number thing so just regex that part
sleep
for like 30 seconds to a minute before all the titles register.