2023-05-09 10:42:03 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-05-30 02:27:12 +00:00
|
|
|
# Looks up argument instead, if provided
|
|
|
|
word=${1:-$(xclip -o)}
|
|
|
|
[ -z "$word" ] && exit 1
|
2023-05-09 10:42:03 +00:00
|
|
|
|
2023-05-30 02:27:12 +00:00
|
|
|
dict_lookup=$(sdcv -n --utf8-output -e "$word")
|
|
|
|
if echo "$dict_lookup" | grep -F -q "Nothing similar to"; then
|
|
|
|
popup "$dict_lookup"
|
2023-05-28 11:15:50 +00:00
|
|
|
else
|
2023-05-30 02:27:12 +00:00
|
|
|
output=$(echo "$dict_lookup" | tail -n +5 | sed 's|<br>|\n|g' | sed 's|<[^>]*>||g')
|
|
|
|
output=$(echo "$output" | sed -E 's/&(amp|lt|gt|quot);/\1/g')
|
2023-05-30 02:31:55 +00:00
|
|
|
output=$(echo "$output" | perl -pe 's/<[^>]*>//g')
|
2023-05-30 02:27:12 +00:00
|
|
|
printf '%s\0' "$output" | xargs -0 -I {} sh -c 'popup "$@"' _ {}
|
2023-05-28 11:15:50 +00:00
|
|
|
fi
|