TextSnatcher icon indicating copy to clipboard operation
TextSnatcher copied to clipboard

1-line command to enter "Take Screenshot"?

Open R8s6 opened this issue 3 years ago • 6 comments

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!

R8s6 avatar May 19 '22 17:05 R8s6

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.

RajSolai avatar May 20 '22 16:05 RajSolai

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?

schlagmichdoch avatar Aug 09 '23 11:08 schlagmichdoch

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 !

RajSolai avatar Aug 09 '23 12:08 RajSolai

@RajSolai Any update on this? :)

schlagmichdoch avatar Sep 20 '23 00:09 schlagmichdoch

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

RajSolai avatar Sep 20 '23 15:09 RajSolai

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%-*}"
}

R8s6 avatar Nov 07 '23 22:11 R8s6

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.

Kommynct avatar Mar 14 '24 07:03 Kommynct

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.

R8s6 avatar Mar 14 '24 19:03 R8s6