RajSolai / TextSnatcher

How to Copy Text from Images ? Answer is TextSnatcher !. Perform OCR operations in seconds on Linux Desktop.
https://textsnatcher.rf.gd/
GNU General Public License v3.0
1.29k stars 46 forks source link

1-line command to enter "Take Screenshot"? #26

Closed R8s6 closed 6 months ago

R8s6 commented 2 years ago

Hi,

Now if I'd like to use "Take Screenshot", I have to launch the program, hit the "Snatch Now!" button, then the "Take Screenshot" button.

I'd like to set up a keyboard shortcut to get into "Take Screenshot" directly, so can I ask if there's a 1-line commandline (or an alternative way) to achieve this?

Thanks!

RajSolai commented 2 years ago

There isn't any command line interface for TextSnatcher, I think having a command for that would be great thank for the suggestion the next version would have the cli support baked in.

schlagmichdoch commented 1 year ago

Bumping this.

TextSnatcher still works really well, thanks for this project!

Moving over from the TextExtractor tool from PowerToys on Windows, I would also like to add a keyboard shortcut (Super+Shift+T) to directly select an area and move the contents to the clipboard.

Is there any progress on the implementation of the cli?

RajSolai commented 1 year ago

Hello there Guys I feel your need for a single command line I have also made some coding for that only thing is I'm not able to compile and test it in a proper Linux machine (As I'm out of town), as soon as I reach my Linux workspace I will test and push this feature, thanks for all your support guys !

schlagmichdoch commented 1 year ago

@RajSolai Any update on this? :)

RajSolai commented 1 year ago

Yes guys the feature is implemented in branch port-gtk here is the ref commit 526e0ab263c1d64966ce380ca642d74fcf5adacb. You can try building the branch to test it out soon I will update the master and app.

Thanks Guys

R8s6 commented 11 months ago

Hi @RajSolai

Thank you so much for the update!

I tried it on Arch, it almost worked (on xfce with x11), everything appears good except in the end no text is copied to clipboard.

Here's how I did it:

I used PKGBUILD based on textsnatcher-git but made modifications:

...
pkgver=2.0.0.r20.g04e89cd
...
depends=('granite7' 'libhandy' 'libportal' 'tesseract') # change granite to granite7
...
source=("${pkgname%-*}::git+${url}.git#branch=port-gtk4")

Built it, installed it, then i ran textsnatcher --screenshot.

It appears to run, with a "cross" for me to select text, all looking good.

But at the end the selected text was not pasted (only a previously copied text was pasted).

Here's the log:

$ textsnatcher --screenshot

(process:85286): Gdk-CRITICAL **: 14:31:10.111: gdk_display_get_clipboard: assertion 'GDK_IS_DISPLAY (display)' failed
OUTPUT : textsnatcher-git-

I don't know if this has anything to do with Xfce i'm using which is not based on gtk4 I guess?

Here's the full PKGBUILD used:

# Maintainer: Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor:

pkgname=textsnatcher-git
pkgver=2.0.0.r20.g04e89cd
pkgrel=1
pkgdesc='Copy Text from Images with ease, Perform OCR operations in seconds'
arch=('x86_64')
url="https://github.com/RajSolai/TextSnatcher"
license=('GPL3')
depends=('granite' 'libhandy' 'libportal' 'tesseract')
makedepends=('git' 'meson' 'vala' granite7)
optdepends=('scrot: screenshot engine for X11 systems'
            'xdg-desktop-portal: for wayland support, you will need the implementation for your wayland desktop environment')
provides=("${pkgname%-*}")
conflicts=("${pkgname%-*}")
source=("${pkgname%-*}::git+${url}.git#branch=port-gtk4")
sha256sums=('SKIP')

pkgver() {
  cd "${pkgname%-*}"
  git describe --long --tags | sed -r 's/([^-]*-g)/r\1/;s/^v//;s/-/./g'
}

build() {
  arch-meson "${pkgname%-*}" build
  ninja -C build
}

package() {
  DESTDIR="$pkgdir" ninja -C build install
  ln -s com.github.rajsolai.textsnatcher "$pkgdir/usr/bin/${pkgname%-*}"
}
Kommynct commented 6 months ago

Honestly, if you want CLI, I see no reason to use textsnatcher, just use tesseract natively, you can always hookup something like the following:

bind = SUPER_ALT, s, exec, grim -g "$(slurp -b 00000000 -s cc000090 -w 0)" - | tesseract -l "eng" stdin stdout | wl-copy && pw-play --volume=0.05 /usr/share/sounds/freedesktop/stereo/camera-shutter.oga

The point of textsnatcher is a nice gui so you don't have to deal with cli.

R8s6 commented 6 months ago

thanks for the recommendation, although it didn't work for me but it did give me an idea to pipe flameshot which i've already been using and feed to tesseract like you did.

Some fun solutions can be found here: https://github.com/flameshot-org/flameshot/issues/702

As it solves my problem, and your point is right, this tool is meant to be a GUI, not a CLI. so case closed.