summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-03-02 13:09:31 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-03-02 13:09:31 +0100
commitc9145e69d0ac6e9e23f8bafa117e83e524cc1354 (patch)
treefa276a8ab0cfe3645bb636410ddb05a88214a30f
parenta52690d8e6e050b1a8610cf3a40c20ba21777f57 (diff)
refactor imgclip
-rwxr-xr-xbin/guiscripts/imgclip26
1 files 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)" "<i>$($clipo)</i>"
+text="$(clipo | tesseract - stdout | sed '/^$/d')"
+[ $? -gt 0 ] && exit 1
+choice="$(printf -- "-\n%s" "$text" | commander -cl)"
+[ "$choice" ] && printf "%s" "$text" | clipp