Merge branch 'searchengines'
[surf.git] / config.def.h
1 /* modifier 0 means no modifier */
2 static int surfuseragent    = 1;  /* Append Surf version to default WebKit user agent */
3 static char *fulluseragent  = ""; /* Or override the whole user agent string */
4 static char *scriptfile     = "~/.surf/script.js";
5 static char *styledir       = "~/.surf/styles/";
6 static char *certdir        = "~/.surf/certificates/";
7 static char *cachedir       = "~/.surf/cache/";
8 static char *cookiefile     = "~/.surf/cookies.txt";
9
10 static SearchEngine searchengines[] = {
11     { "g",    "https://www.google.com/search?q=%s"             },
12     { "ji",   "https://jisho.org/search/%s"                    },
13     { "aw",   "https://wiki.archlinux.org/index.php?search=%s" }
14 };
15
16 /* Webkit default features */
17 /* Highest priority value will be used.
18  * Default parameters are priority 0
19  * Per-uri parameters are priority 1
20  * Command parameters are priority 2
21  */
22 static Parameter defconfig[ParameterLast] = {
23         /* parameter                    Arg value       priority */
24         [AcceleratedCanvas]   =       { { .i = 1 },     },
25         [AccessMicrophone]    =       { { .i = 0 },     },
26         [AccessWebcam]        =       { { .i = 0 },     },
27         [Certificate]         =       { { .i = 0 },     },
28         [CaretBrowsing]       =       { { .i = 0 },     },
29         [CookiePolicies]      =       { { .v = "@Aa" }, },
30         [DefaultCharset]      =       { { .v = "UTF-8" }, },
31         [DiskCache]           =       { { .i = 1 },     },
32         [DNSPrefetch]         =       { { .i = 0 },     },
33         [FileURLsCrossAccess] =       { { .i = 0 },     },
34         [FontSize]            =       { { .i = 12 },    },
35         [FrameFlattening]     =       { { .i = 0 },     },
36         [Geolocation]         =       { { .i = 0 },     },
37         [HideBackground]      =       { { .i = 0 },     },
38         [Inspector]           =       { { .i = 0 },     },
39         [Java]                =       { { .i = 1 },     },
40         [JavaScript]          =       { { .i = 1 },     },
41         [KioskMode]           =       { { .i = 0 },     },
42         [LoadImages]          =       { { .i = 1 },     },
43         [MediaManualPlay]     =       { { .i = 1 },     },
44         [Plugins]             =       { { .i = 1 },     },
45         [PreferredLanguages]  =       { { .v = (char *[]){ NULL } }, },
46         [RunInFullscreen]     =       { { .i = 0 },     },
47         [ScrollBars]          =       { { .i = 1 },     },
48         [ShowIndicators]      =       { { .i = 1 },     },
49         [SiteQuirks]          =       { { .i = 1 },     },
50         [SmoothScrolling]     =       { { .i = 0 },     },
51         [SpellChecking]       =       { { .i = 0 },     },
52         [SpellLanguages]      =       { { .v = ((char *[]){ "en_US", NULL }) }, },
53         [StrictTLS]           =       { { .i = 1 },     },
54         [Style]               =       { { .i = 1 },     },
55         [WebGL]               =       { { .i = 0 },     },
56         [ZoomLevel]           =       { { .f = 1.0 },   },
57 };
58
59 static UriParameters uriparams[] = {
60         { "(://|\\.)suckless\\.org(/|$)", {
61           [JavaScript] = { { .i = 0 }, 1 },
62           [Plugins]    = { { .i = 0 }, 1 },
63         }, },
64 };
65
66 /* default window size: width, height */
67 static int winsize[] = { 800, 600 };
68
69 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
70                                     WEBKIT_FIND_OPTIONS_WRAP_AROUND;
71
72 #define PROMPT_GO   "Go:"
73 #define PROMPT_FIND "Find:"
74
75 /* SETPROP(readprop, setprop, prompt)*/
76 #define SETPROP(r, s, p) { \
77         .v = (const char *[]){ "/bin/sh", "-c", \
78              "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
79              "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\" && cat ~/.surf/bookmarks)\" " \
80              "| dmenu -l 10 -p \"$4\" -w $1)\" && " \
81              "xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
82              "surf-setprop", winid, r, s, p, NULL \
83         } \
84 }
85
86 /* DOWNLOAD(URI, referer) */
87 #define DOWNLOAD(u, r) { \
88         .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
89              "curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \
90              " -e \"$3\" \"$4\"; read", \
91              "surf-download", useragent, cookiefile, r, u, NULL \
92         } \
93 }
94
95 /* PLUMB(URI) */
96 /* This called when some URI which does not begin with "about:",
97  * "http://" or "https://" should be opened.
98  */
99 #define PLUMB(u) {\
100         .v = (const char *[]){ "/bin/sh", "-c", \
101              "xdg-open \"$0\"", u, NULL \
102         } \
103 }
104
105 /* VIDEOPLAY(URI) */
106 #define VIDEOPLAY(u) {\
107         .v = (const char *[]){ "/bin/sh", "-c", \
108              "mpv --really-quiet \"$0\"", u, NULL \
109         } \
110 }
111
112 /* BM_ADD(readprop) */
113 #define BM_ADD(r) {\
114         .v = (const char *[]){ "/bin/sh", "-c", \
115              "(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \
116              "| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.surf/bookmarks) " \
117              "| awk '!seen[$0]++' > ~/.surf/bookmarks.tmp && " \
118              "mv ~/.surf/bookmarks.tmp ~/.surf/bookmarks", \
119              winid, r, NULL \
120         } \
121 }
122
123 /* styles */
124 /*
125  * The iteration will stop at the first match, beginning at the beginning of
126  * the list.
127  */
128 static SiteSpecific styles[] = {
129         /* regexp               file in $styledir */
130         { ".*",                 "default.css" },
131 };
132
133 /* certificates */
134 /*
135  * Provide custom certificate for urls
136  */
137 static SiteSpecific certs[] = {
138         /* regexp               file in $certdir */
139         { "://suckless\\.org/", "suckless.org.crt" },
140 };
141
142 #define MODKEY GDK_CONTROL_MASK
143
144 /* hotkeys */
145 /*
146  * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
147  * edit the CLEANMASK() macro.
148  */
149 static Key keys[] = {
150         /* modifier              keyval          function    arg */
151         { MODKEY,                GDK_KEY_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
152         { MODKEY,                GDK_KEY_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
153         { MODKEY,                GDK_KEY_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
154         { MODKEY,                GDK_KEY_m,      spawn,      BM_ADD("_SURF_URI") },
155
156         { 0,                     GDK_KEY_Escape, stop,       { 0 } },
157         { MODKEY,                GDK_KEY_c,      stop,       { 0 } },
158
159         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r,      reload,     { .i = 1 } },
160         { MODKEY,                GDK_KEY_r,      reload,     { .i = 0 } },
161
162         { MODKEY,                GDK_KEY_l,      navigate,   { .i = +1 } },
163         { MODKEY,                GDK_KEY_h,      navigate,   { .i = -1 } },
164
165         /* vertical and horizontal scrolling, in viewport percentage */
166         { MODKEY,                GDK_KEY_j,      scrollv,    { .i = +10 } },
167         { MODKEY,                GDK_KEY_k,      scrollv,    { .i = -10 } },
168         { MODKEY,                GDK_KEY_space,  scrollv,    { .i = +50 } },
169         { MODKEY,                GDK_KEY_b,      scrollv,    { .i = -50 } },
170         { MODKEY,                GDK_KEY_i,      scrollh,    { .i = +10 } },
171         { MODKEY,                GDK_KEY_u,      scrollh,    { .i = -10 } },
172
173
174         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j,      zoom,       { .i = -1 } },
175         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k,      zoom,       { .i = +1 } },
176         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q,      zoom,       { .i = 0  } },
177         { MODKEY,                GDK_KEY_minus,  zoom,       { .i = -1 } },
178         { MODKEY,                GDK_KEY_plus,   zoom,       { .i = +1 } },
179
180         { MODKEY,                GDK_KEY_p,      clipboard,  { .i = 1 } },
181         { MODKEY,                GDK_KEY_y,      clipboard,  { .i = 0 } },
182
183         { MODKEY,                GDK_KEY_n,      find,       { .i = +1 } },
184         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n,      find,       { .i = -1 } },
185
186         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p,      print,      { 0 } },
187         { MODKEY,                GDK_KEY_t,      showcert,   { 0 } },
188
189         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a,      togglecookiepolicy, { 0 } },
190         { 0,                     GDK_KEY_F11,    togglefullscreen, { 0 } },
191         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o,      toggleinspector, { 0 } },
192
193         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c,      toggle,     { .i = CaretBrowsing } },
194         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f,      toggle,     { .i = FrameFlattening } },
195         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g,      toggle,     { .i = Geolocation } },
196         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s,      toggle,     { .i = JavaScript } },
197         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i,      toggle,     { .i = LoadImages } },
198         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v,      toggle,     { .i = Plugins } },
199         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b,      toggle,     { .i = ScrollBars } },
200         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t,      toggle,     { .i = StrictTLS } },
201         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m,      toggle,     { .i = Style } },
202 };
203
204 /* button definitions */
205 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
206 static Button buttons[] = {
207         /* target       event mask      button  function        argument        stop event */
208         { OnLink,       0,              2,      clicknewwindow, { .i = 0 },     1 },
209         { OnLink,       MODKEY,         2,      clicknewwindow, { .i = 1 },     1 },
210         { OnLink,       MODKEY,         1,      clicknewwindow, { .i = 1 },     1 },
211         { OnAny,        0,              8,      clicknavigate,  { .i = -1 },    1 },
212         { OnAny,        0,              9,      clicknavigate,  { .i = +1 },    1 },
213         { OnMedia,      MODKEY,         1,      clickexternplayer, { 0 },       1 },
214 };
215
216 #define HOMEPAGE "https://duckduckgo.com/"