Fix websearch plugin

Make yahoo search use the correct url. Quieten output from browser
unless there is an error.
This commit is contained in:
Tom Cammann 2014-09-29 23:56:54 +01:00
commit ad72b56906

View file

@ -16,16 +16,19 @@ function web_search() {
return 1 return 1
fi fi
local url="${WEB_SEARCH_PROTOCOL:-https}://www.$1.com" local url="${WEB_SEARCH_PROTOCOL:-https}://www.$1.${WEB_SEARCH_TLD:-com}"
# no keyword provided, simply open the search engine homepage # no keyword provided, simply open the search engine homepage
if [[ $# -le 1 ]]; then if [[ $# -le 1 ]]; then
$open_cmd "$url" $open_cmd "$url"
return return
fi fi
#
# slightly different search syntax for duckduckgo and yahoo
if [[ $1 == 'duckduckgo' ]]; then if [[ $1 == 'duckduckgo' ]]; then
#slightly different search syntax for DDG
url="${url}/?q=" url="${url}/?q="
elif [[ $1 == 'yahoo' ]]; then
url="${WEB_SEARCH_PROTOCOL:-https}://search.$1.com/search?p="
else else
url="${url}/search?q=" url="${url}/search?q="
fi fi
@ -37,8 +40,14 @@ function web_search() {
done done
url="${url%?}" # remove the last '+' url="${url%?}" # remove the last '+'
nohup $open_cmd "$url" local error_file="$(mktemp -t websearchXXXX)"
rm nohup.out $open_cmd "$url" 2> ${error_file}
echo $url
local exit_code=$?
if [[ ${exit_code} != 0 ]]; then
cat $error_file 2>&1
fi
return ${exit_code}
} }