Re:TextSnatcher: Copy text from images, for the Linux Desktop
by boneitis on Friday March 15, 2024 @10:05PM
(#39722692)
I just frankenstein'd a few people's versions into my own MATE-based flavor.
For anyone running into barriers, mate-screenshot has no outfile `-f` option, so I worked around that by outputting through clipboard and capturing that with `xclip` (note, this is earlier in the script than the the xsel/xclip line in the parent and gp comments):
mate-screenshot -a -c && xclip -selection clipboard -t image/png -o > "$SCR_IMG/scr.png" || die "failed to take screenshot"
The other hiccup is that the dumped text file has two extraneous bytes '\x0a\x0c', so I truncated them with `head`: (xclip -selection clipboard -i < <(head -c -2 "$SCR_IMG/scr.txt")) || die "failed to copy text to clipboard"
Might not be pretty, but it looks like this will work for me. Thank you all for this!
Also made some minor modifications: replaced `xsel` with `xclip` and added truncated version of the copied text to the `notify-send`: