You are not logged in.
Hi there!
I'll preface this by saying I'm a huge fan of XFCE, and have been for many years.
When I discovered custom actions in Screenshooter about an hour ago, I was immediately in love with them!
However, I have one small question.
In my Keyboard settings, in the Application Shortcuts, I have set up a couple different shortcuts for Screenshooter:
xfce4-screenshooter -w Print
xfce4-screenshooter -f Shift+Print
xfce4-screenshooter -rc Shift+Super+S
And I was wondering if it was possible to add another one, with which I could select an area (-r) and then pipe it into one of the Custom Actions that I've set up, like an OCR one or the QR code one.
It would be really nice if I could just hit a hotkey, select an area, and then get the text from that area copied into my clipboard immediately.
Almost like -rc, except instead of an image, it's text.
Of course, I already looked in the --help menu, but I couldn't see anything referring to the new Custom Actions there.
I also looked at the bug tracker, but nothing about this there either.
Thanks for reading!
And thanks for the super amazing software, too!
Last edited by TechnicJelle (2024-03-25 02:05:32)
Offline
Hello and welcome.
What is the source that you are using to capture the image to OCR? An image file with text?
Here is an interesting experiment. With xclip and tesseract (and the appropriate tesseract language data file) installed, run the following command:
xfce4-screenshooter -r -s /tmp/save.png && tesseract /tmp/save.png - | xclip
...when prompted with the screenshooter crosshairs, select the text you want. Then look into your clipboard.
If it works satisfactorily, create a shortcut for it.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Hi!
Yes, the source for the image would be a normal xfce4-screenshooter -r.
Currently, I'm just using the examples from the docs, but I'm planning on looking into a different program to handle the OCR-ing.
So currently, I'm just using
gimagereader-gtk %f
But what you suggested sounds exactly like what I wanted!
I tried it out just now, and almost works.
It just doesn't actually copy the text to the clipboard.
If I run it from a terminal, instead of the keyboard shortcut, it also doesn't work.
And if I leave out the last pipe into xclip, it prints exactly what I want!
So there must be something not quite right with that yet.
I looked it up, and it seems to be an issue with the fact that xclip relinquishes control over the clipboard too soon, so the copied text gets lost, I think? (source)
So I tried that nohup program, but I don't think I'm using it right, because it still doesn't work.
It did print this a little while after I ran it, though:
Use the -Toops @ option (default). Make the X selection indefinitely available, until another
process requests ownership of the X selection.
However, binding the program to a keyboard shortcut kil the xclip daemon after it returns. This
behavior is not present when launching the program from a terminal. The -verbose option keeps
the program running in the foreground, which causes the terminal to be kept around as well.
To keep the xclip daemon running, with no terminal window visible, an option is to use the
nohup. program. It runs a command which will have the init process as PPID (e.g. systemd).
But I think it's a bit too late in the night for me to fully understand what this entails.
Oh wait, scratch that!
It is in the clipboard, but it's just not in the Ctrl+V clipboard, or something like that?
I can paste it by pressing the middle mouse button, instead, according to Clipman.
Maybe I just need to study how clipboards work on Linux a bit more.
Thanks for the leg-up already, in any case!
I'm heading to bed, now, though.
Offline
If you have clipman installed and on your panel, make sure "Sync mouse selections" is selected. For me Ctrl+V works.
Some initial links to get a better understanding of clipboards:
- xfce4-clipman doc page
- arch wiki page
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
I didn't know about that setting, thanks!
When I run the command from my terminal, now, it indeed works exactly like I wanted to! Thank you!
However, when I copy that command into my keyboard shortcuts, it doesn't work any more...
I'll read up more on the way Clipman (and clipboards on Linux and X11 in general) work!
Offline
However, when I copy that command into my keyboard shortcuts, it doesn't work any more...
The Keyboard shortcuts command can't handle special characters well. Try running them within a temporary shell:
sh -c 'xfce4-screenshooter -r -s /tmp/save.png && tesseract /tmp/save.png - | xclip'
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Yeah, now it works!! Thank you so much!!
However, I think that "Sync mouse selections" setting does more than I want it to.
It seems as though it now copies everything I select, even before I press Ctrl+C.
I'm assuming this is a normal thing, but is there maybe a way to turn that off?
In fact, I noticed this when opening the keyboard shortcuts section.
I double-clicked on the entry for the Screenshooter OCR, and the command was automatically pre-selected for me.
So when I pressed Ctrl+V to paste the command I had copied from your message, it did not paste at all.
It seemed like nothing happened, but that's because it was pasting itself overtop itself.
Very interesting behaviours!
Maybe I'll stick to keeping that option off, after all, and having to remember that, to paste the OCR'd text, I have to click my middle mouse button, instead of using Ctrl+V, like normal.
Last edited by TechnicJelle (2024-03-25 21:42:27)
Offline
I have some examples of OCR custom actions in my project here:
Offline
[ Generated in 0.015 seconds, 9 queries executed - Memory usage: 570.21 KiB (Peak: 587.05 KiB) ]