From c9145e69d0ac6e9e23f8bafa117e83e524cc1354 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 2 Mar 2024 13:09:31 +0100 Subject: refactor imgclip --- bin/guiscripts/imgclip | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/bin/guiscripts/imgclip b/bin/guiscripts/imgclip index 466f2c6..eeac050 100755 --- a/bin/guiscripts/imgclip +++ b/bin/guiscripts/imgclip @@ -1,23 +1,5 @@ #!/bin/sh - -tmppic="/tmp/imgclip.png" -if [ "$WAYLAND_DISPLAY" ] -then - clipo='wl-paste -n' - clipp='wl-copy -n' -else - clipo='xclip -o -selection clipboard -r' - clipp='xclip -selection clipboard -r' -fi - -$clipo > $tmppic 2>/dev/null -ftype="$(file /tmp/imgclip.png -bi | cut -f 1 -d ';')" -if [ "$ftype" != image/png ] -then - notify-send "$(basename $0)" "Not an image." - exit 1 -fi - -tesseract "$tmppic" stdout | $clipp - -notify-send "$(basename $0)" "$($clipo)" +text="$(clipo | tesseract - stdout | sed '/^$/d')" +[ $? -gt 0 ] && exit 1 +choice="$(printf -- "-\n%s" "$text" | commander -cl)" +[ "$choice" ] && printf "%s" "$text" | clipp -- cgit v1.2.3