summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitsuo Tokumori <[email protected]>2023-12-08 12:37:11 -0500
committerMitsuo Tokumori <[email protected]>2023-12-08 12:37:11 -0500
commitfbb95d86079a624309306acf93e6cbee226ffbdd (patch)
treeded6b54462d5c360b0f9cd950b1998b23cdc4234
parentaa7371bf6fddc16fd97d6ec9d58df4b81430f3d4 (diff)
downloaddotfiles-fbb95d86079a624309306acf93e6cbee226ffbdd.tar.gz
dotfiles-fbb95d86079a624309306acf93e6cbee226ffbdd.tar.bz2
dotfiles-fbb95d86079a624309306acf93e6cbee226ffbdd.zip
Add screenshot_ocr.sh
-rw-r--r--config/xorg/xbindkeysrc7
-rwxr-xr-xlocal/bin/screenshot_ocr.sh23
2 files changed, 28 insertions, 2 deletions
diff --git a/config/xorg/xbindkeysrc b/config/xorg/xbindkeysrc
index 20c458c..e5f4841 100644
--- a/config/xorg/xbindkeysrc
+++ b/config/xorg/xbindkeysrc
@@ -71,9 +71,9 @@
# Modifier scheme (order: Control,Shift,Alt(Mod1),Super(Mod4)):
# * app-specific:
-# * Control, Control+Shift
+# * Control, Control+Shift, Contrl+Alt (*)
# * Linux & WM (dwm):
-# * Alt, Control+Alt, Shift+Alt
+# * Alt, Control+Alt (*), Shift+Alt
# * user-defined:
# * Mod4 (application launch & audio control)
# * Shift+Mod4 (brightness control & audio control)
@@ -138,6 +138,9 @@
"screenshot.sh screen"
Shift + Print
+"screenshot_ocr.sh"
+ Mod4 + s
+
# This key combination (Mod4 + Space) seems to break xbindkeys
# See Also:
# https://bbs.archlinux.org/viewtopic.php?id=226182
diff --git a/local/bin/screenshot_ocr.sh b/local/bin/screenshot_ocr.sh
new file mode 100755
index 0000000..de84d93
--- /dev/null
+++ b/local/bin/screenshot_ocr.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# Select a region of the screen and perform OCR to it. Save text in clipboard.
+
+savepath="/tmp/screenshot_ocr.sh.d"
+filename="$HOSTNAME-$(date -Iseconds | tr -d ':-').png"
+tesseract_options="-l eng"
+
+_init() {
+ if [ ! -d "$savepath" ]; then
+ mkdir -p "$savepath"
+ fi
+ cd /tmp/screenshot_ocr.sh.d
+}
+
+_init
+# screenshot region of screen
+shotgun -g $(hacksaw) "$filename"
+# exit if previous command was unsuccessful
+test $? -ne 0 && exit
+# perform OCR and save to clipboard
+tesseract $tesseract_options $filename - | xclip -selection "clipboard"
+rm $filename