18 lines
444 B
Bash
Executable file
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
|