2019-03-30 04:07:48 +00:00
|
|
|
#!/bin/sh
|
2018-12-19 09:28:09 +00:00
|
|
|
# Gives a dmenu prompt to search DuckDuckGo.
|
|
|
|
# Without input, will open DuckDuckGo.com.
|
|
|
|
# URLs will be directly handed to the browser.
|
|
|
|
# Anything else, it search it.
|
2018-12-19 09:18:29 +00:00
|
|
|
browser=${BROWSER:-firefox}
|
2018-10-11 23:45:23 +00:00
|
|
|
|
|
|
|
pgrep -x dmenu && exit
|
|
|
|
|
2018-12-19 09:28:09 +00:00
|
|
|
choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1
|
2018-10-11 23:45:23 +00:00
|
|
|
|
2018-12-19 09:28:09 +00:00
|
|
|
if [ "$choice" = "🦆" ]; then
|
2018-12-19 09:18:29 +00:00
|
|
|
$browser "https://duckduckgo.com"
|
2018-10-11 23:45:23 +00:00
|
|
|
else
|
2019-03-30 04:07:48 +00:00
|
|
|
if echo "$choice" | grep "^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$"; then
|
2018-12-19 09:28:09 +00:00
|
|
|
$browser "$choice"
|
2018-12-19 09:18:29 +00:00
|
|
|
else
|
2018-12-19 09:28:09 +00:00
|
|
|
$browser "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
|
2018-12-19 09:18:29 +00:00
|
|
|
fi
|
2018-10-11 23:45:23 +00:00
|
|
|
fi
|