suckless_dictpopup/dictpopup
2023-05-13 21:22:42 +02:00

15 lines
438 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
echo "$dict_lookup" | tail -n +5 | sed 's|<br>|\n|g' | sed 's|<[^>]*>||g' | xargs -d '\n' popup
fi
# Instead of sed also possible:
# `lynx -dump -stdin -assume_charset=UTF-8 -display_charset=UTF-8`