voidrice/.scripts/i3cmds/ducksearch
2018-12-19 10:18:29 +01:00

18 lines
444 B
Bash
Executable file

#!/bin/sh
browser=${BROWSER:-firefox}
pgrep -x dmenu && exit
query=$(echo "duckduckgo.com" | dmenu -i -p "Search DuckDuckGo:") || exit 1
if [ "$query" = "duckduckgo.com" ]; then
$browser "https://duckduckgo.com"
else
# Detect if url
if [[ "$query" =~ ^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+.[a-zA-Z]+(/)?.*$ ]]; then
$browser "$query"
else
$browser "https://duckduckgo.com/?q=$query&t=ffab&atb=v1-1"
fi
fi