summaryrefslogtreecommitdiff
path: root/.local/bin/websearch
blob: 2de2c75e80e28e511a49530dde8a0100a3a19be3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh
# Gives a dmenu prompt to search Google.
# Without input, will open Google.com.
# URLs will be directly handed to the browser.
# Anything else, it search it.

query=$(printf "                                        " | dmenu -i -p  " Search Google")

echo "$query" | head -c 1

if [ $(echo "$query" | head -c 1) == "\!" ]; then
 $BROWSER "https://duckduckgo.com/?q=$query&t=ffab&atb=v1-1"
else
 $BROWSER "https://google.com/?q=$query&t=ffab&atb=v1-1"
fi


# # pgrep -x dmenu && exit
# # pgrep -x dmenu

# choice=$(echo "" | dmenu -i -p " Search DuckDuckGo") || exit 1

# if [ "$choice" = ""  ]; then
#     firefox "https://duckduckgo.com"
# else
#     if echo "$choice" | grep "^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$"; then
#         firefox "$choice"
#     else
#         firefox "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
#     fi
# fi