summaryrefslogtreecommitdiffstats
path: root/.scripts/i3cmds/ducksearch
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2018-12-19 07:50:43 -0500
committerGitHub <noreply@github.com>2018-12-19 07:50:43 -0500
commit4f53a2425bb5a4c3bfaf8ff5aace8bbd0159f3a4 (patch)
tree9136b3cdb61725b12083cace78376aa73eff00ea /.scripts/i3cmds/ducksearch
parent3220b115987a086b93a10a7e650ee282f951da4d (diff)
parent69296d87d7d1f4aa1b1c6f9a4cb7f571036bb388 (diff)
downloadeibhear-4f53a2425bb5a4c3bfaf8ff5aace8bbd0159f3a4.tar.gz
eibhear-4f53a2425bb5a4c3bfaf8ff5aace8bbd0159f3a4.tar.zst
eibhear-4f53a2425bb5a4c3bfaf8ff5aace8bbd0159f3a4.zip
Merge pull request #160 from anders-dc/ducksearch
Detect http urls in ducksearch and directly connect to them
Diffstat (limited to '.scripts/i3cmds/ducksearch')
-rwxr-xr-x.scripts/i3cmds/ducksearch11
1 files changed, 9 insertions, 2 deletions
diff --git a/.scripts/i3cmds/ducksearch b/.scripts/i3cmds/ducksearch
index 13a1e19..4e79570 100755
--- a/.scripts/i3cmds/ducksearch
+++ b/.scripts/i3cmds/ducksearch
@@ -2,14 +2,21 @@
# 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
choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1
if [ "$choice" = "🦆" ]; then
- $BROWSER "https://duckduckgo.com"
+ $browser "https://duckduckgo.com"
else
- $BROWSER "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
+ # Detect if url
+ if [[ "$choice" =~ ^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$ ]]; then
+ $browser "$choice"
+ else
+ $browser "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
+ fi
fi