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 *cachedir = "~/.surf/cache/";
7 static char *cookiefile = "~/.surf/cookies.txt";
9 /* Webkit default features */
10 static Parameter defconfig[ParameterLast] = {
11 SETB(CaretBrowsing, 0),
12 SETV(CookiePolicies, "@Aa"),
16 SETB(FrameFlattening, 0),
18 SETB(HideBackground, 0),
24 SETV(PreferredLanguages, ((char *[]){ NULL })),
25 SETB(RunInFullscreen, 0),
27 SETB(ShowIndicators, 1),
28 SETB(SpellChecking, 0),
29 SETV(SpellLanguages, ((char *[]){ "en_US", NULL })),
35 static UriParameters uriparams[] = {
36 { "(://|\\.)suckless\\.org(/|$)", {
42 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
43 WEBKIT_FIND_OPTIONS_WRAP_AROUND;
45 #define SETPROP(p, q) { \
46 .v = (const char *[]){ "/bin/sh", "-c", \
47 "prop=\"`xprop -id $2 $0 " \
48 "| sed \"s/^$0(STRING) = \\(\\\\\"\\?\\)\\(.*\\)\\1$/\\2/\" " \
49 "| xargs -0 printf %b | dmenu`\" &&" \
50 "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
55 /* DOWNLOAD(URI, referer) */
56 #define DOWNLOAD(d, r) { \
57 .v = (const char *[]){ "/bin/sh", "-c", \
58 "st -e /bin/sh -c \"curl -g -L -J -O --user-agent '$1'" \
59 " --referer '$2' -b $3 -c $3 '$0';" \
61 d, useragent, r, cookiefile, NULL \
66 /* This called when some URI which does not begin with "about:",
67 * "http://" or "https://" should be opened.
70 .v = (const char *[]){ "/bin/sh", "-c", \
71 "xdg-open \"$0\"", u, NULL \
76 #define VIDEOPLAY(u) {\
77 .v = (const char *[]){ "/bin/sh", "-c", \
78 "mpv --really-quiet \"$0\"", u, NULL \
84 * The iteration will stop at the first match, beginning at the beginning of
87 static SiteStyle styles[] = {
88 /* regexp file in $styledir */
89 { ".*", "default.css" },
92 #define MODKEY GDK_CONTROL_MASK
96 * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
97 * edit the CLEANMASK() macro.
100 /* modifier keyval function arg */
101 { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") },
102 { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
103 { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
105 { 0, GDK_KEY_Escape, stop, { 0 } },
106 { MODKEY, GDK_KEY_c, stop, { 0 } },
108 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .b = 1 } },
109 { MODKEY, GDK_KEY_r, reload, { .b = 0 } },
111 { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
112 { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
114 /* Currently we have to use scrolling steps that WebKit2GTK+ gives us
115 * d: step down, u: step up, r: step right, l:step left
116 * D: page down, U: page up */
117 { MODKEY, GDK_KEY_j, scroll, { .i = 'd' } },
118 { MODKEY, GDK_KEY_k, scroll, { .i = 'u' } },
119 { MODKEY, GDK_KEY_b, scroll, { .i = 'U' } },
120 { MODKEY, GDK_KEY_space, scroll, { .i = 'D' } },
121 { MODKEY, GDK_KEY_i, scroll, { .i = 'r' } },
122 { MODKEY, GDK_KEY_u, scroll, { .i = 'l' } },
125 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
126 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
127 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
128 { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
129 { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
131 { MODKEY, GDK_KEY_p, clipboard, { .b = 1 } },
132 { MODKEY, GDK_KEY_y, clipboard, { .b = 0 } },
134 { MODKEY, GDK_KEY_n, find, { .i = +1 } },
135 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
137 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
139 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
140 { 0, GDK_KEY_F11, togglefullscreen, { 0 } },
141 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } },
142 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, togglestyle, { 0 } },
144 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } },
145 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } },
146 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } },
147 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } },
148 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } },
149 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } },
150 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
151 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
154 /* button definitions */
155 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
156 static Button buttons[] = {
157 /* target event mask button function argument stop event */
158 { OnLink, 0, 2, clicknewwindow, { .b = 0 }, 1 },
159 { OnLink, MODKEY, 2, clicknewwindow, { .b = 1 }, 1 },
160 { OnLink, MODKEY, 1, clicknewwindow, { .b = 1 }, 1 },
161 { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
162 { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
163 { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },