Last active
March 8, 2022 07:06
-
-
Save Amooti73/94dc1efe2fd120d6735cf0a3b21e2994 to your computer and use it in GitHub Desktop.
Click and drag to select a word or words on the screen and send them to rofi and then display the introductory section of the matching wikipedia article.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Dependencies: tesseract-ocr imagemagick scrot xsel wikit rofi | |
set -e | |
SCR_IMG=$(mktemp) | |
trap 'rm $SCR_IMG*' EXIT | |
scrot -s "$SCR_IMG.png" | |
mogrify -modulate 100,0 -resize 400% "$SCR_IMG.png" #should increase detection rate | |
tesseract "$SCR_IMG.png" "$SCR_IMG" &> /dev/null | |
cat "$SCR_IMG.txt" > wordy.txt | |
tr -d '\014' <wordy.txt > words.txt | |
src=$(cat words.txt) | |
test "$src" = "$(cat words.txt)" | |
rofi="rofi -dmenu -yoffset 30 -location 2" | |
pag() { \ | |
eval "$rofi" -l 20 -p 'Done' | |
} | |
phrase=$(echo "$src"|eval "$rofi -markup -p 'Lookup '") | |
{ | |
wikit "$phrase" --line 80 --link | |
} | pag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This depends on wikit which must be installed with npm. It makes of this script which was posted on AskUbuntu.