aboutsummaryrefslogtreecommitdiff
path: root/config.dot/surfraw.link/elvi/searx
blob: 01b535fe8ea454cf78e59ae483788e4f8f35489c (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
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
86
87
#!/bin/sh
# elvis: searx           -- Search using searx metasearch engine instances (https://searx.me and others)
# author: ng0            -- contact: ng0@we.make.ritual.n0.is
# 2016-08-14

. surfraw || exit 1

w3_config_hook () {
    def SURFRAW_searx_categories  "$SURFRAW_categories"
    def SURFRAW_searx_base_url    "$SURFRAW_url"
}

w3_usage_hook () {
    cat <<EOF

Usage: $w3_argv0 [options] [search words]...
Description:
  Use the searx metasearch engine

 -category,c=CATEGORIES

  Local options:
    default   | search category "general" (default)
    vid       | search category "videos"
    socialm   | search category "social+media"
    news      | search category "news"
    music     | search category "music"
    map       | search category "map"
    it        | search category "it"
    img       | search category "images"
    files     | search category "files"
                 Default: general

 -url,u=URL

  Local options:
    1       | https://searx.me
    2       | https://searx.laquadrature.net
    3       | https://www.privatesearch.io
    o1      | http://searchb5a7tmimez.onion (laquadrature)
    o2      | http://ulrn6sryqaifefld.onion (searx.me)
    cjdns   | fc00:59dd:3bb2:d592:4083:c138:5489:560a
                  Default: https://searx.me

EOF
    w3_global_usage
}

w3_parse_option_hook () {
    opt="$1"
    optarg="$2"
    case "$opt" in
    -c*=*)   setopt   SURFRAW_searx_categories   $optarg ;;
    -u*=*)   setopt   SURFRAW_searx_base_url     $optarg ;;
    *) return 1 ;;
    esac
    return 0
}

w3_config
w3_parse_args "$@"

case "$SURFRAW_searx_categories" in
    default*)   category="general"        ;;
    vid*)       category="videos"         ;;
    socialm*)   category="social+media"   ;;
    news*)      category="news"           ;;
    music*)     category="music"          ;;
    map*)       category="map"            ;;
    it*)        category="it"             ;;
    img*)       category="images"         ;;
    files*)     category="files"          ;;
    *)          category="general"        ;;
esac
case "$SURFRAW_searx_base_url" in
    1*)   searx_url="https://searx.me"         ;;
    2*)         searx_url="https://searx.laquadrature.net" ;;
    3*)         searx_url="https://www.privatesearch.io" ;;
    o1*)        searx_url="http://searchb5a7tmimez.onion" ;;
    o2*)        searx_url="http://ulrn6sryqaifefld.onion" ;;
    cjdns*)     searx_url="fc00:59dd:3bb2:d592:4083:c138:5489:560a" ;;
    *)          searx_url="https://searx.me" ;;
esac
# w3_args now contains a list of arguments
escaped_args=$(w3_url_of_arg $w3_args)

w3_browse_url "${searx_url}/?q=${escaped_args}&categories=${category}"