diff options
| author | Anders Damsgaard <anders@adamsgaard.dk> | 2018-12-19 10:18:29 +0100 |
|---|---|---|
| committer | Anders Damsgaard <anders@adamsgaard.dk> | 2018-12-19 10:18:29 +0100 |
| commit | 6833d840778897b2304195b13ac75d2a96c08a72 (patch) | |
| tree | 4dce3d560d4ab35c0f5e7c6107a05cc0cfa52d2b /.scripts/i3cmds/ducksearch | |
| parent | 1adb9b9002a85f3cd79157c381fe2cf7835eda42 (diff) | |
| download | eibhear-6833d840778897b2304195b13ac75d2a96c08a72.tar.gz eibhear-6833d840778897b2304195b13ac75d2a96c08a72.tar.zst eibhear-6833d840778897b2304195b13ac75d2a96c08a72.zip | |
Detect http urls in query and directly connect to them
Diffstat (limited to '.scripts/i3cmds/ducksearch')
| -rwxr-xr-x | .scripts/i3cmds/ducksearch | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/.scripts/i3cmds/ducksearch b/.scripts/i3cmds/ducksearch index 13a1e19..2f09675 100755 --- a/.scripts/i3cmds/ducksearch +++ b/.scripts/i3cmds/ducksearch @@ -1,15 +1,18 @@ #!/bin/sh -# Gives a dmenu prompt to search DuckDuckGo. -# Without input, will open DuckDuckGo.com. -# Anything else, it search it. +browser=${BROWSER:-firefox} pgrep -x dmenu && exit -choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1 +query=$(echo "duckduckgo.com" | dmenu -i -p "Search DuckDuckGo:") || exit 1 -if [ "$choice" = "🦆" ]; then - $BROWSER "https://duckduckgo.com" +if [ "$query" = "duckduckgo.com" ]; then + $browser "https://duckduckgo.com" else - $BROWSER "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1" + # 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 |
