Fix weird behavior and simplify even more.
This commit is contained in:
parent
d51775ab63
commit
1ee5529f31
16
dictpopup
16
dictpopup
|
@ -1,14 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Looks up argument instead, if provided
|
if [ "$1" == "html" ] || [ "$1" == "HTML" ]; then
|
||||||
word=${1:-$(xclip -o)}
|
word=${2:-$(sselp)}
|
||||||
[ -z "$word" ] && exit 1
|
sdcv -n --utf8-output -e "$word" | perl -pe 's/<[^>]*>//g' | popup
|
||||||
|
|
||||||
dict_lookup=$(sdcv -n --utf8-output -e "$word")
|
|
||||||
if echo "$dict_lookup" | grep -F -q "Nothing similar to"; then
|
|
||||||
popup "$dict_lookup"
|
|
||||||
else
|
else
|
||||||
output=$(echo "$dict_lookup" | tail -n +5 | sed 's|<br>|\n|g')
|
word=${1:-$(sselp)}
|
||||||
output=$(echo "$output" | perl -pe 's/<[^>]*>//g')
|
sdcv -n --utf8-output -e "$word" | perl -pe 's/<[^>]*>//g' | popup
|
||||||
printf '%s\0' "$output" | xargs -0 -I {} sh -c 'popup "$@"' _ {}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue