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 static char *historyfile = "~/.surf/history.txt";
11 static SearchEngine searchengines[] = {
12 { "g", "https://www.google.com/search?q=%s" },
13 { "ji", "https://jisho.org/search/%s" },
14 { "aw", "https://wiki.archlinux.org/index.php?search=%s" },
15 { "s", "https://searx.danieliu.xyz/?q=%s" }
18 /* Webkit default features */
19 /* Highest priority value will be used.
20 * Default parameters are priority 0
21 * Per-uri parameters are priority 1
22 * Command parameters are priority 2
24 static Parameter defconfig[ParameterLast] = {
25 /* parameter Arg value priority */
26 [AcceleratedCanvas] = { { .i = 1 }, },
27 [AccessMicrophone] = { { .i = 0 }, },
28 [AccessWebcam] = { { .i = 0 }, },
29 [Certificate] = { { .i = 0 }, },
30 [CaretBrowsing] = { { .i = 0 }, },
31 [CookiePolicies] = { { .v = "@Aa" }, },
32 [DefaultCharset] = { { .v = "UTF-8" }, },
33 [DiskCache] = { { .i = 1 }, },
34 [DNSPrefetch] = { { .i = 0 }, },
35 [FileURLsCrossAccess] = { { .i = 0 }, },
36 [FontSize] = { { .i = 12 }, },
37 [FrameFlattening] = { { .i = 0 }, },
38 [Geolocation] = { { .i = 0 }, },
39 [HideBackground] = { { .i = 0 }, },
40 [Inspector] = { { .i = 0 }, },
41 [Java] = { { .i = 1 }, },
42 [JavaScript] = { { .i = 1 }, },
43 [KioskMode] = { { .i = 0 }, },
44 [LoadImages] = { { .i = 1 }, },
45 [MediaManualPlay] = { { .i = 1 }, },
46 [Plugins] = { { .i = 1 }, },
47 [PreferredLanguages] = { { .v = (char *[]){ NULL } }, },
48 [RunInFullscreen] = { { .i = 0 }, },
49 [ScrollBars] = { { .i = 1 }, },
50 [ShowIndicators] = { { .i = 1 }, },
51 [SiteQuirks] = { { .i = 1 }, },
52 [SmoothScrolling] = { { .i = 0 }, },
53 [SpellChecking] = { { .i = 0 }, },
54 [SpellLanguages] = { { .v = ((char *[]){ "en_US", NULL }) }, },
55 [StrictTLS] = { { .i = 1 }, },
56 [Style] = { { .i = 1 }, },
57 [WebGL] = { { .i = 0 }, },
58 [ZoomLevel] = { { .f = 1.0 }, },
61 static UriParameters uriparams[] = {
62 { "(://|\\.)suckless\\.org(/|$)", {
63 [JavaScript] = { { .i = 0 }, 1 },
64 [Plugins] = { { .i = 0 }, 1 },
68 /* default window size: width, height */
69 static int winsize[] = { 800, 600 };
71 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
72 WEBKIT_FIND_OPTIONS_WRAP_AROUND;
74 #define PROMPT_GO "Go:"
75 #define PROMPT_FIND "Find:"
77 /* SETPROP(readprop, setprop, prompt)*/
78 #define SETPROP(r, s, p) { \
79 .v = (const char *[]){ "/bin/sh", "-c", \
80 "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
81 "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\" && cat ~/.surf/bookmarks)\" " \
82 "| dmenu -l 10 -p \"$4\" -w $1)\" && " \
83 "xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
84 "surf-setprop", winid, r, s, p, NULL \
88 /* DOWNLOAD(URI, referer) */
89 #define DOWNLOAD(u, r) { \
90 .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
91 "curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \
92 " -e \"$3\" \"$4\"; read", \
93 "surf-download", useragent, cookiefile, r, u, NULL \
98 /* This called when some URI which does not begin with "about:",
99 * "http://" or "https://" should be opened.
102 .v = (const char *[]){ "/bin/sh", "-c", \
103 "xdg-open \"$0\"", u, NULL \
108 #define VIDEOPLAY(u) {\
109 .v = (const char *[]){ "/bin/sh", "-c", \
110 "notify-send 'Opening video in mpv...' & mpv --really-quiet \"$0\"", u, NULL \
114 /* BM_ADD(readprop) */
116 .v = (const char *[]){ "/bin/sh", "-c", \
117 "(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \
118 "| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.surf/bookmarks) " \
119 "| awk '!seen[$0]++' > ~/.surf/bookmarks.tmp && " \
120 "mv ~/.surf/bookmarks.tmp ~/.surf/bookmarks", \
125 #define SETURI(p) { .v = (char *[]){ "/bin/sh", "-c", \
126 "prop=\"`surf_history_dmenu.sh`\" &&" \
127 "xprop -id $1 -f $0 8s -set $0 \"$prop\"", \
132 * The iteration will stop at the first match, beginning at the beginning of
135 static SiteSpecific styles[] = {
136 /* regexp file in $styledir */
137 { ".*", "default.css" },
142 * Provide custom certificate for urls
144 static SiteSpecific certs[] = {
145 /* regexp file in $certdir */
146 { "://suckless\\.org/", "suckless.org.crt" },
149 #define MODKEY GDK_CONTROL_MASK
153 * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
154 * edit the CLEANMASK() macro.
156 static Key keys[] = {
157 /* modifier keyval function arg */
158 { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
159 { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
160 { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
161 { MODKEY, GDK_KEY_m, spawn, BM_ADD("_SURF_URI") },
163 { MODKEY, GDK_KEY_w, playexternal, { 0 } },
165 { 0, GDK_KEY_Escape, stop, { 0 } },
166 { MODKEY, GDK_KEY_c, stop, { 0 } },
168 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
169 { MODKEY, GDK_KEY_r, reload, { .i = 0 } },
171 { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
172 { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
174 /* vertical and horizontal scrolling, in viewport percentage */
175 { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } },
176 { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } },
177 { MODKEY, GDK_KEY_space, scrollv, { .i = +50 } },
178 { MODKEY, GDK_KEY_b, scrollv, { .i = -50 } },
179 { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } },
180 { MODKEY, GDK_KEY_u, scrollh, { .i = -10 } },
183 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
184 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
185 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
186 { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
187 { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
189 { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } },
190 { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } },
192 { MODKEY, GDK_KEY_n, find, { .i = +1 } },
193 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
195 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
196 { MODKEY, GDK_KEY_t, showcert, { 0 } },
198 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
199 { 0, GDK_KEY_F11, togglefullscreen, { 0 } },
200 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } },
202 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } },
203 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } },
204 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } },
205 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } },
206 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } },
207 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } },
208 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
209 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } },
210 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
211 { MODKEY , GDK_KEY_Return, spawn, SETURI("_SURF_GO") },
214 /* button definitions */
215 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
216 static Button buttons[] = {
217 /* target event mask button function argument stop event */
218 { OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 },
219 { OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 },
220 { OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 },
221 { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
222 { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
223 { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },
226 #define HOMEPAGE "https://danieliu.xyz/"