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 /* Webkit default features */
11 static Parameter defconfig[ParameterLast] = {
12 SETB(AcceleratedCanvas, 1),
14 SETB(CaretBrowsing, 0),
15 SETV(CookiePolicies, "@Aa"),
16 SETV(DefaultCharset, "UTF-8"),
20 SETB(FrameFlattening, 0),
22 SETB(HideBackground, 0),
27 SETB(MediaManualPlay, 0),
29 SETV(PreferredLanguages, ((char *[]){ NULL })),
30 SETB(RunInFullscreen, 0),
32 SETB(ShowIndicators, 1),
34 SETB(SpellChecking, 0),
35 SETV(SpellLanguages, ((char *[]){ "en_US", NULL })),
41 static UriParameters uriparams[] = {
42 { "(://|\\.)suckless\\.org(/|$)", {
48 /* default window size: width, height */
49 static int winsize[] = { 800, 600 };
51 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
52 WEBKIT_FIND_OPTIONS_WRAP_AROUND;
54 #define PROMPT_GO "Go:"
55 #define PROMPT_FIND "Find:"
57 /* SETPROP(readprop, setprop, prompt)*/
58 #define SETPROP(r, s, p) { \
59 .v = (const char *[]){ "/bin/sh", "-c", \
60 "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
61 "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \
62 "| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
63 "surf-setprop", winid, r, s, p, NULL \
67 /* DOWNLOAD(URI, referer) */
68 #define DOWNLOAD(u, r) { \
69 .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
70 "curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \
71 " -e \"$3\" \"$4\"; read", \
72 "surf-download", useragent, cookiefile, r, u, NULL \
77 /* This called when some URI which does not begin with "about:",
78 * "http://" or "https://" should be opened.
81 .v = (const char *[]){ "/bin/sh", "-c", \
82 "xdg-open \"$0\"", u, NULL \
87 #define VIDEOPLAY(u) {\
88 .v = (const char *[]){ "/bin/sh", "-c", \
89 "mpv --really-quiet \"$0\"", u, NULL \
95 * The iteration will stop at the first match, beginning at the beginning of
98 static SiteSpecific styles[] = {
99 /* regexp file in $styledir */
100 { ".*", "default.css" },
105 * Provide custom certificate for urls
107 static SiteSpecific certs[] = {
108 /* regexp file in $certdir */
109 { "://suckless\\.org/", "suckless.org.crt" },
112 #define MODKEY GDK_CONTROL_MASK
116 * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
117 * edit the CLEANMASK() macro.
119 static Key keys[] = {
120 /* modifier keyval function arg */
121 { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
122 { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
123 { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
125 { 0, GDK_KEY_Escape, stop, { 0 } },
126 { MODKEY, GDK_KEY_c, stop, { 0 } },
128 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .b = 1 } },
129 { MODKEY, GDK_KEY_r, reload, { .b = 0 } },
131 { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
132 { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
134 /* Currently we have to use scrolling steps that WebKit2GTK+ gives us
135 * d: step down, u: step up, r: step right, l:step left
136 * D: page down, U: page up */
137 { MODKEY, GDK_KEY_j, scroll, { .i = 'd' } },
138 { MODKEY, GDK_KEY_k, scroll, { .i = 'u' } },
139 { MODKEY, GDK_KEY_b, scroll, { .i = 'U' } },
140 { MODKEY, GDK_KEY_space, scroll, { .i = 'D' } },
141 { MODKEY, GDK_KEY_i, scroll, { .i = 'r' } },
142 { MODKEY, GDK_KEY_u, scroll, { .i = 'l' } },
145 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
146 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
147 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
148 { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
149 { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
151 { MODKEY, GDK_KEY_p, clipboard, { .b = 1 } },
152 { MODKEY, GDK_KEY_y, clipboard, { .b = 0 } },
154 { MODKEY, GDK_KEY_n, find, { .i = +1 } },
155 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
157 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
158 { MODKEY, GDK_KEY_t, showcert, { 0 } },
160 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
161 { 0, GDK_KEY_F11, togglefullscreen, { 0 } },
162 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } },
164 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } },
165 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } },
166 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } },
167 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } },
168 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } },
169 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } },
170 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
171 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } },
172 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
175 /* button definitions */
176 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
177 static Button buttons[] = {
178 /* target event mask button function argument stop event */
179 { OnLink, 0, 2, clicknewwindow, { .b = 0 }, 1 },
180 { OnLink, MODKEY, 2, clicknewwindow, { .b = 1 }, 1 },
181 { OnLink, MODKEY, 1, clicknewwindow, { .b = 1 }, 1 },
182 { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
183 { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
184 { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },