voidrice/.local/bin/i3cmds/ducksearch

21 lines
580 B
Text
Raw Normal View History

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.
browser=${BROWSER:-firefox}
pgrep -x dmenu && exit
2018-12-19 09:28:09 +00:00
choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1
2018-12-19 09:28:09 +00:00
if [ "$choice" = "🦆" ]; then
$browser "https://duckduckgo.com"
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"
else
2018-12-19 09:28:09 +00:00
$browser "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
fi
fi