16 lines
513 B
Bash
Executable file
16 lines
513 B
Bash
Executable file
#!/bin/sh
|
|
|
|
# Looks up argument instead, if provided
|
|
word=${1:-$(xclip -o)}
|
|
[ -z "$word" ] && exit 1
|
|
|
|
dict_lookup=$(sdcv -n --utf8-output -e "$word")
|
|
if echo "$dict_lookup" | grep -F -q "Nothing similar to"; then
|
|
popup "$dict_lookup"
|
|
else
|
|
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')
|
|
output=$(echo "$output" | perl -pe 's/<[^>]*>//g')
|
|
printf '%s\0' "$output" | xargs -0 -I {} sh -c 'popup "$@"' _ {}
|
|
fi
|