~anjan/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] ocr_roi.sh commit & README.md update

Details
Message ID
<20240210215022.16710-1-hallo@magdesign.ch>
DKIM signature
permerror
Download raw message
Patch: +58 -0
---
 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
Details
Message ID
<CZ59YSM8TTRH.C6G4S4VMAV6I@momi.ca>
In-Reply-To
<20240210215022.16710-1-hallo@magdesign.ch> (view parent)
DKIM signature
pass
Download raw message
Thanks!

To git@git.sr.ht:~anjan/sxmo-userscripts
   07e21dd..e06af5d  master -> master

--
w:] www.momi.ca
pgp:] https://momi.ca/publickey.txt
Reply to thread Export thread (mbox)