-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmsearch
executable file
·85 lines (80 loc) · 3.43 KB
/
dmsearch
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
#
# Script name: dmsearch
# Description: Search various search engines (inspired by surfraw).
# Dependencies: dmenu and a web browser
# GitLab: https://www.gitlab.com/dwt1/dmscripts
# License: https://www.gitlab.com/dwt1/dmscripts/LICENSE
# Original Contributors: Derek Taylor
# Ali Furkan Yıldız
# Modified by : Bharath Saiguhan
# Defining our web browser.
DMBROWSER="brave"
# An array of search engines. You can edit this list to add/remove
# search engines. The format must be: "engine_name - url".
# The url format must allow for the search keywords at the end of the url.
# For example: https://www.amazon.com/s?k=XXXX searches Amazon for 'XXXX'.
declare -a options=(
"amazon - https://www.amazon.com/s?k="
"archaur - https://aur.archlinux.org/packages/?O=0&K="
#"archpkg - https://archlinux.org/packages/?sort=&q="
"archwiki - https://wiki.archlinux.org/index.php?search="
"arxiv - https://arxiv.org/search/?searchtype=all&source=header&query="
"astropy - https://docs.astropy.org/en/stable/search.html?q="
#"bbcnews - https://www.bbc.co.uk/search?q="
#"cliki - https://www.cliki.net/site/search?query="
#"cnn - https://www.cnn.com/search?q="
#"coinbase - https://www.coinbase.com/price?query="
#"debianpkg - https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords="
#"discogs - https://www.discogs.com/search/?&type=all&q="
"duckduckgo - https://duckduckgo.com/?q="
#"ebay - https://www.ebay.com/sch/i.html?&_nkw="
"github - https://github.com/search?q="
"gitlab - https://gitlab.com/search?search="
"google - https://www.google.com/search?q="
"googleimages - https://www.google.com/search?hl=en&tbm=isch&q="
#"googlenews - https://news.google.com/search?q="
#"imdb - https://www.imdb.com/find?q="
"matplotlib - https://matplotlib.org/stable/search.html?q="
"numpy - https://numpy.org/doc/stable/search.html?q="
"python - https://docs.python.org/3/search.html?q="
#"lbry - https://lbry.tv/$/search?q="
#"odysee - https://odysee.com/$/search?q="
#"reddit - https://www.reddit.com/search/?q="
"scipy - https://docs.scipy.org/doc/scipy/reference/search.html?q="
#"slashdot - https://slashdot.org/index2.pl?fhfilter="
#"socialblade - https://socialblade.com/youtube/user/"
#"sourceforge - https://sourceforge.net/directory/?q="
"stack - https://stackoverflow.com/search?q="
#"startpage - https://www.startpage.com/do/dsearch?query="
#"stockquote - https://finance.yahoo.com/quote/"
#"thesaurus - https://www.thesaurus.com/misspelling?term="
#"translate - https://translate.google.com/?sl=auto&tl=en&text="
#"urban - https://www.urbandictionary.com/define.php?term="
#"wayback - https://web.archive.org/web/*/"
#"webster - https://www.merriam-webster.com/dictionary/"
"wikipedia - https://en.wikipedia.org/wiki/"
#"wiktionary - https://en.wiktionary.org/wiki/"
"wolfram - https://www.wolframalpha.com/input/?i="
"youtube - https://www.youtube.com/results?search_query="
"quit"
)
# Picking a search engine.
while [ -z "$engine" ]
do
enginelist=$(printf '%s\n' "${options[@]}" | dmenu -i -c -bw 2 -l 20 -p 'Choose search engine:') || exit
engineurl=$(echo "$enginelist" | awk '{print $NF}')
engine=$(echo "$enginelist" | awk '{print $1}')
done
# Searching the chosen engine.
while [ -z "$query" ]
do
if [[ "$engine" == "quit" ]]
then
echo "Program terminated." && exit 0
else
query=$(echo "$engine" | dmenu -c -bw 2 -p 'Enter search query:') || exit
fi
done
# Display search results in web browser
$DMBROWSER "$engineurl""$query"