Using gocr and flameshot to get text from images

From time to time I have the need to get text from an image, when someone shares an screen-shot, but not the URL in it or wanting to copy code from a stopped youtube video. I know there are browser plugins, that utilize some webservices to OCR, but it wanted a solution that works "everywhere" on my desktop.

First install gocr and flameshot. Then create a script, that runs gocr with and open the result (in my case I want to open an terminal with vim). E.g. ~/bin/ocr:

rxvt -e sh -c "gocr -i \"$1\" | vim -"

Then create a "desktop" entry for flameshot to pick up. ~/.local/share/applications/ocr.desktop:

[Desktop Entry]
Exec=.../bin/ocr %f

(Note, that the path there is absolute, or you have to figure out, what works for you... I couldn't be bothered to look into this)

Then start flameshot gui (I have that on my Print Screen-key), select the region to OCR, press CTRL-o (or click the button to open the screenshot with an application), then pick the OCR-Application from the desktop entry, which should open the text.