traches@sh.itjust.workstoAsk Lemmy@lemmy.world•What does your OS do that I should steal?English
18·
2 days agoGrim, slurp, tesseract, and apparently the deepl SDK for Ruby? That was an interesting choice, younger me.
#! /bin/zsh
# Select an area of the screen, Screenhot, OCR, and translate it to english.
temp_image=$(mktemp --suffix '.png')
grim -g "$(slurp)" "$temp_image"
# DPI of 120 seems to work OK for screenshots.
source_text=$(tesseract "$temp_image" - --dpi 120 -l pol+deu)
translated_text=$(~/scripts/translate "$source_text")
wl-copy $translated_text
notify-send 'Translation: ' "$translated_text" --expire-time=60000 --category 'translation'
rm $temp_image
Translate script:
#! /bin/ruby
require_relative 'deepl_request'
puts Translator::DeeplRequest
.new(ARGV.join ' ')
.translation
This script is a bit hacky and one-off, I wouln’t just copy-paste it.
Agreed, that should be many tens of pages not one. Also the mobile layout isn’t very good. I think it’s important to remember that normies use their phones for almost everything.