Get rid of config parameter MACROs
[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 /* Webkit default features */
11 static Parameter defconfig[ParameterLast] = {
12         /*   parameter                  Arg value       force? */
13         [AcceleratedCanvas]   =       { { .i = 1 },     },
14         [AccessMicrophone]    =       { { .i = 0 },     },
15         [AccessWebcam]        =       { { .i = 0 },     },
16         [Certificate]         =       { { .i = 0 },     },
17         [CaretBrowsing]       =       { { .i = 0 },     },
18         [CookiePolicies]      =       { { .v = "@Aa" }, },
19         [DefaultCharset]      =       { { .v = "UTF-8" }, },
20         [DiskCache]           =       { { .i = 1 },     },
21         [DNSPrefetch]         =       { { .i = 0 },     },
22         [FileURLsCrossAccess] =       { { .i = 0 },     },
23         [FontSize]            =       { { .i = 12 },    },
24         [FrameFlattening]     =       { { .i = 0 },     },
25         [Geolocation]         =       { { .i = 0 },     },
26         [HideBackground]      =       { { .i = 0 },     },
27         [Inspector]           =       { { .i = 0 },     },
28         [Java]                =       { { .i = 1 },     },
29         [JavaScript]          =       { { .i = 1 },     },
30         [KioskMode]           =       { { .i = 0 },     },
31         [LoadImages]          =       { { .i = 1 },     },
32         [MediaManualPlay]     =       { { .i = 0 },     },
33         [Plugins]             =       { { .i = 1 },     },
34         [PreferredLanguages]  =       { { .v = (char *[]){ NULL } }, },
35         [RunInFullscreen]     =       { { .i = 0 },     },
36         [ScrollBars]          =       { { .i = 1 },     },
37         [ShowIndicators]      =       { { .i = 1 },     },
38         [SiteQuirks]          =       { { .i = 1 },     },
39         [SmoothScrolling]     =       { { .i = 0 },     },
40         [SpellChecking]       =       { { .i = 0 },     },
41         [SpellLanguages]      =       { { .v = ((char *[]){ "en_US", NULL }) }, },
42         [StrictTLS]           =       { { .i = 1 },     },
43         [Style]               =       { { .i = 1 },     },
44         [ZoomLevel]           =       { { .f = 1.0 },   },
45 };
46
47 static UriParameters uriparams[] = {
48         { "(://|\\.)suckless\\.org(/|$)", {
49           [JavaScript] = { { .i = 0 }, 1 },
50           [Plugins]    = { { .i = 0 }, 1 },
51         }, },
52 };
53
54 /* default window size: width, height */
55 static int winsize[] = { 800, 600 };
56
57 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
58                                     WEBKIT_FIND_OPTIONS_WRAP_AROUND;
59
60 #define PROMPT_GO   "Go:"
61 #define PROMPT_FIND "Find:"
62
63 /* SETPROP(readprop, setprop, prompt)*/
64 #define SETPROP(r, s, p) { \
65         .v = (const char *[]){ "/bin/sh", "-c", \
66              "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
67              "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \
68              "| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
69              "surf-setprop", winid, r, s, p, NULL \
70         } \
71 }
72
73 /* DOWNLOAD(URI, referer) */
74 #define DOWNLOAD(u, r) { \
75         .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
76              "curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \
77              " -e \"$3\" \"$4\"; read", \
78              "surf-download", useragent, cookiefile, r, u, NULL \
79         } \
80 }
81
82 /* PLUMB(URI) */
83 /* This called when some URI which does not begin with "about:",
84  * "http://" or "https://" should be opened.
85  */
86 #define PLUMB(u) {\
87         .v = (const char *[]){ "/bin/sh", "-c", \
88              "xdg-open \"$0\"", u, NULL \
89         } \
90 }
91
92 /* VIDEOPLAY(URI) */
93 #define VIDEOPLAY(u) {\
94         .v = (const char *[]){ "/bin/sh", "-c", \
95              "mpv --really-quiet \"$0\"", u, NULL \
96         } \
97 }
98
99 /* styles */
100 /*
101  * The iteration will stop at the first match, beginning at the beginning of
102  * the list.
103  */
104 static SiteSpecific styles[] = {
105         /* regexp               file in $styledir */
106         { ".*",                 "default.css" },
107 };
108
109 /* certificates */
110 /*
111  * Provide custom certificate for urls
112  */
113 static SiteSpecific certs[] = {
114         /* regexp               file in $certdir */
115         { "://suckless\\.org/", "suckless.org.crt" },
116 };
117
118 #define MODKEY GDK_CONTROL_MASK
119
120 /* hotkeys */
121 /*
122  * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
123  * edit the CLEANMASK() macro.
124  */
125 static Key keys[] = {
126         /* modifier              keyval          function    arg */
127         { MODKEY,                GDK_KEY_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
128         { MODKEY,                GDK_KEY_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
129         { MODKEY,                GDK_KEY_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
130
131         { 0,                     GDK_KEY_Escape, stop,       { 0 } },
132         { MODKEY,                GDK_KEY_c,      stop,       { 0 } },
133
134         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r,      reload,     { .i = 1 } },
135         { MODKEY,                GDK_KEY_r,      reload,     { .i = 0 } },
136
137         { MODKEY,                GDK_KEY_l,      navigate,   { .i = +1 } },
138         { MODKEY,                GDK_KEY_h,      navigate,   { .i = -1 } },
139
140         /* Currently we have to use scrolling steps that WebKit2GTK+ gives us
141          * d: step down, u: step up, r: step right, l:step left
142          * D: page down, U: page up */
143         { MODKEY,                GDK_KEY_j,      scroll,     { .i = 'd' } },
144         { MODKEY,                GDK_KEY_k,      scroll,     { .i = 'u' } },
145         { MODKEY,                GDK_KEY_b,      scroll,     { .i = 'U' } },
146         { MODKEY,                GDK_KEY_space,  scroll,     { .i = 'D' } },
147         { MODKEY,                GDK_KEY_i,      scroll,     { .i = 'r' } },
148         { MODKEY,                GDK_KEY_u,      scroll,     { .i = 'l' } },
149
150
151         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j,      zoom,       { .i = -1 } },
152         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k,      zoom,       { .i = +1 } },
153         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q,      zoom,       { .i = 0  } },
154         { MODKEY,                GDK_KEY_minus,  zoom,       { .i = -1 } },
155         { MODKEY,                GDK_KEY_plus,   zoom,       { .i = +1 } },
156
157         { MODKEY,                GDK_KEY_p,      clipboard,  { .i = 1 } },
158         { MODKEY,                GDK_KEY_y,      clipboard,  { .i = 0 } },
159
160         { MODKEY,                GDK_KEY_n,      find,       { .i = +1 } },
161         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n,      find,       { .i = -1 } },
162
163         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p,      print,      { 0 } },
164         { MODKEY,                GDK_KEY_t,      showcert,   { 0 } },
165
166         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a,      togglecookiepolicy, { 0 } },
167         { 0,                     GDK_KEY_F11,    togglefullscreen, { 0 } },
168         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o,      toggleinspector, { 0 } },
169
170         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c,      toggle,     { .i = CaretBrowsing } },
171         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f,      toggle,     { .i = FrameFlattening } },
172         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g,      toggle,     { .i = Geolocation } },
173         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s,      toggle,     { .i = JavaScript } },
174         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i,      toggle,     { .i = LoadImages } },
175         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v,      toggle,     { .i = Plugins } },
176         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b,      toggle,     { .i = ScrollBars } },
177         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t,      toggle,     { .i = StrictTLS } },
178         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m,      toggle,     { .i = Style } },
179 };
180
181 /* button definitions */
182 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
183 static Button buttons[] = {
184         /* target       event mask      button  function        argument        stop event */
185         { OnLink,       0,              2,      clicknewwindow, { .i = 0 },     1 },
186         { OnLink,       MODKEY,         2,      clicknewwindow, { .i = 1 },     1 },
187         { OnLink,       MODKEY,         1,      clicknewwindow, { .i = 1 },     1 },
188         { OnAny,        0,              8,      clicknavigate,  { .i = -1 },    1 },
189         { OnAny,        0,              9,      clicknavigate,  { .i = +1 },    1 },
190         { OnMedia,      MODKEY,         1,      clickexternplayer, { 0 },       1 },
191 };