From 5dca4a76b4f1d517cee544e939c33b84e540cae7 Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 2 Aug 2022 16:43:28 -0700 Subject: [PATCH] Added russian OCR screenshot --- modules/screenshot/init.lua | 17 ++++++++++++++--- modules/screenshot/screenshot.fish | 12 +++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/modules/screenshot/init.lua b/modules/screenshot/init.lua index e764c11..f8f0fab 100644 --- a/modules/screenshot/init.lua +++ b/modules/screenshot/init.lua @@ -20,17 +20,28 @@ return { } ), - awful.key( {"Control"}, "Print", + awful.key( {"Control", "Shift"}, "Print", function () - screenshot_action("ocr") + screenshot_action("ocr-rus") end, { - description = "OCR Capture", + description = "OCR Capture (Russian)", group = "Screenshot" } ), + awful.key( {"Control"}, "Print", + function () + screenshot_action("ocr-eng") + end, + + { + description = "OCR Capture (English)", + group = "Screenshot" + } + ), + awful.key( {"Shift"}, "Print", function () screenshot_action("pin") diff --git a/modules/screenshot/screenshot.fish b/modules/screenshot/screenshot.fish index 5575595..97df369 100755 --- a/modules/screenshot/screenshot.fish +++ b/modules/screenshot/screenshot.fish @@ -23,7 +23,7 @@ function capture case pin flameshot gui --accept-on-select --pin - case ocr + case ocr-eng flameshot gui --accept-on-select --path $tmp_file # Recognize text @@ -33,6 +33,16 @@ function capture echo $ocr | sed -e "s/^[ \t]*//" | xclip -i -rmlastnl -selection clipboard rm $tmp_file + case ocr-rus + flameshot gui --accept-on-select --path $tmp_file + + # Recognize text + set ocr (tesseract --dpi 96 -l rus $tmp_file stdout) + + # Trim whitespace and copy to clipboard + echo $ocr | sed -e "s/^[ \t]*//" | xclip -i -rmlastnl -selection clipboard + rm $tmp_file + case "*" echo "Unknown action \"$argv[1]\""