[PATCH] ocr_roi.sh commit & README.md update
Export this patch
---
scripts/README.md | 10 ++++++++++
scripts/ocr_roi.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
create mode 100755 scripts/ocr_roi.sh
diff --git a/scripts/README.md b/scripts/README.md
index 9e1249b..3cd3ccc 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -114,3 +114,13 @@ Copy the script to `$XDG_CONFIG_HOME/sxmo/userscripts` and make it executable.
- Author: Aljoscha Hartmann
- License: GPL3+
- Descripton: Small script that calls nmcli radio off/on respectively for "Airplane Mode".
+
+## ssh_toggle.sh
+- Author: magdesign
+- License: MIT
+- Descripton: Toggle ssh on/off
+
+## ocr_roi.sh
+- Author: magdesign
+- License: MIT
+- Descripton: Screencapture text to clipboard
diff --git a/scripts/ocr_roi.sh b/scripts/ocr_roi.sh
new file mode 100755
index 0000000..5b3d34d
--- /dev/null
+++ b/scripts/ocr_roi.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+# title="$icon_prn OCRscreen"
+# Author: magdesign
+# License: MIT4
+# Description: Reads text of selected area
+# Requirements: bash tesseract-ocr tesseract-ocr-data-eng wl-clipboard
+# Notes: v0.2 Works only in sway/wayland
+# include common definitions
+# shellcheck source=scripts/core/sxmo_common.sh
+. "/usr/bin/sxmo_common.sh"
+
+# check requirements
+if command -v tesseract >/dev/null 2>&1 ;then
+echo "ok"
+else
+ notify-send --urgency=critical "Please install tesseract-ocr tesseract-ocr-data-eng"
+ exit 1
+fi
+
+if command -v wl-paste >/dev/null 2>&1 ;then
+echo "ok"
+else
+ notify-send --urgency=critical "Please install wl-clipboard"
+ exit 1
+fi
+# end of requirements check
+
+# tempdir
+DIR=/tmp/ocr_tmp.png
+
+# create a screenshot of wanted area:
+area="$(slurp -o)"
+grim -g "$area" "$DIR"
+
+# sends image to ocr and extracts text
+tesseract /tmp/ocr_tmp.png /tmp/ocr_tmp
+
+# displays text
+notify-send "$(cat /tmp/ocr_tmp.txt)"
+
+# copy text to clipboard
+cat /tmp/ocr_tmp.txt | wl-copy
+
+# cleanup
+rm /tmp/ocr_tmp.txt
+rm /tmp/ocr_tmp.png
+
+exit
--
2.43.0
Thanks!
To git@git.sr.ht:~anjan/sxmo-userscripts
07e21dd..e06af5d master -> master
--
w:] www.momi.ca
pgp:] https://momi.ca/publickey.txt