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