DuckDuckGo 457 B

123456789101112131415
  1. #!/bin/sh
  2. #terminal="urxvt -e"
  3. #tmpfile="/tmp/ddict.lookup.$$"
  4. #Requires python2-ddg package
  5. word=$(xsel -o | dmenu -p 'DuckDuckGo Lookup:') || exit
  6. while [[ $word != "" ]]; do
  7. oup=$(ddg "$word" 2>&1)
  8. if [[ $? -eq 21 ]]; then
  9. word=$(echo -e "$oup" | cut -d: -f2 | xargs -n1 | sort -u -f | dmenu -p 'Did you mean:') || exit
  10. else
  11. notify-send -a DuckDuckGo -i /home/eddie/.icons/logo_square.64.png "$word" "$oup"
  12. break
  13. fi
  14. done