commit 26973fb
hovercats
·
2025-09-20 10:22:26 +0000 UTC
parent d7027bd
dsearch: add options for using different search engines
1 files changed,
+27,
-5
+27,
-5
1@@ -2,10 +2,32 @@
2
3 flag e +
4
5-ENGINE='https://lite.duckduckgo.com/html?q='
6+fn usage {printf 'Usage: dsearch b|d|s|y <query>\n' && exit 1}
7
8-# Spaces are not allowed, so substitute them to correct string
9-STRING=`{printf '' | dmenu -c -p 'Search' | sed 's/ /%20/g'}
10+fn string {printf '' | dmenu -c -p 'Search'}
11
12-if (~ $#STRING 0) printf 'Usage: dsearch: query\n' && exit 1
13-exec $BROWSER $ENGINE$STRING
14+# search engines
15+DDG='https://lite.duckduckgo.com/html?q='
16+SP='https://www.startpage.com/sp/search?query='
17+BC='https://bandcamp.com/search?q='
18+YT='https://inv.nadeko.net/search?q='
19+
20+switch($1) {
21+ case b
22+ ENGINE=$BC
23+ STRING=`{string | sed 's/ /%2B/g'}
24+ case d
25+ ENGINE=$DDG
26+ STRING=`{string | sed 's/ /%20/g'}
27+ case s
28+ ENGINE=$SP
29+ STRING=`{string | sed 's/ /%20/g'}
30+ case y
31+ ENGINE=$YT
32+ STRING=`{string | sed 's/ /+/g'}
33+ case *
34+ usage
35+}
36+
37+if (~ $#STRING 0) usage
38+exec $"BROWSER $ENGINE$STRING