commit eea6ac3

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