summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x.scripts/i3cmds/ducksearch14
1 files changed, 9 insertions, 5 deletions
diff --git a/.scripts/i3cmds/ducksearch b/.scripts/i3cmds/ducksearch
index 2f09675..2e14513 100755
--- a/.scripts/i3cmds/ducksearch
+++ b/.scripts/i3cmds/ducksearch
@@ -1,18 +1,22 @@
#!/bin/sh
+# 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
-query=$(echo "duckduckgo.com" | dmenu -i -p "Search DuckDuckGo:") || exit 1
+choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1
-if [ "$query" = "duckduckgo.com" ]; then
+if [ "$choice" = "🦆" ]; then
$browser "https://duckduckgo.com"
else
# Detect if url
- if [[ "$query" =~ ^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+.[a-zA-Z]+(/)?.*$ ]]; then
- $browser "$query"
+ if [[ "$choice" =~ ^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+.[a-zA-Z]+(/)?.*$ ]]; then
+ $browser "$choice"
else
- $browser "https://duckduckgo.com/?q=$query&t=ffab&atb=v1-1"
+ $browser "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
fi
fi