tconfig.h - surf - [fork] customized build of surf, the suckless webkit browser (HTM) git clone git://src.adamsgaard.dk/surf (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- tconfig.h (9826B) --- 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 = "~/.config/surf/script.js"; 5 static char *styledir = "~/.config/surf/styles/"; 6 static char *certdir = "~/.config/surf/certificates/"; 7 static char *cachedir = "~/.config/surf/cache/"; 8 static char *cookiefile = "~/.config/surf/cookies.txt"; 9 static char **plugindirs = (char*[]){ 10 "~/.config/surf/plugins/", 11 LIBPREFIX "/mozilla/plugins/", 12 NULL 13 }; 14 15 /* Webkit default features */ 16 /* Highest priority value will be used. 17 * Default parameters are priority 0 18 * Per-uri parameters are priority 1 19 * Command parameters are priority 2 20 */ 21 static Parameter defconfig[ParameterLast] = { 22 /* parameter Arg value priority */ 23 [AccessMicrophone] = { { .i = 0 }, }, 24 [AccessWebcam] = { { .i = 0 }, }, 25 [Certificate] = { { .i = 0 }, }, 26 [CaretBrowsing] = { { .i = 0 }, }, 27 [CookiePolicies] = { { .v = "@Aa" }, }, 28 [DefaultCharset] = { { .v = "UTF-8" }, }, 29 [DiskCache] = { { .i = 1 }, }, 30 [DNSPrefetch] = { { .i = 0 }, }, 31 [FileURLsCrossAccess] = { { .i = 0 }, }, 32 [FontSize] = { { .i = 12 }, }, 33 [FrameFlattening] = { { .i = 0 }, }, 34 [Geolocation] = { { .i = 0 }, }, 35 [HideBackground] = { { .i = 0 }, }, 36 [Inspector] = { { .i = 0 }, }, 37 [Ephemeral] = { { .i = 0 }, }, 38 [Java] = { { .i = 0 }, }, 39 [JavaScript] = { { .i = 0 }, }, 40 [KioskMode] = { { .i = 0 }, }, 41 [LoadImages] = { { .i = 0 }, }, 42 [MediaManualPlay] = { { .i = 1 }, }, 43 [PreferredLanguages] = { { .v = (char *[]){ NULL } }, }, 44 [RunInFullscreen] = { { .i = 0 }, }, 45 [ScrollBars] = { { .i = 1 }, }, 46 [ShowIndicators] = { { .i = 1 }, }, 47 [SiteQuirks] = { { .i = 1 }, }, 48 [SmoothScrolling] = { { .i = 0 }, }, 49 [SpellChecking] = { { .i = 0 }, }, 50 [SpellLanguages] = { { .v = ((char *[]){ "en_US", NULL }) }, }, 51 [StrictTLS] = { { .i = 1 }, }, 52 [Style] = { { .i = 1 }, }, 53 [WebGL] = { { .i = 0 }, }, 54 [ZoomLevel] = { { .f = 1.0 }, }, 55 }; 56 57 static UriParameters uriparams[] = { 58 { "(://|\\.)suckless\\.org(/|$)", { 59 [JavaScript] = { { .i = 0 }, 1 }, 60 }, }, 61 }; 62 63 /* default window size: width, height */ 64 static int winsize[] = { 800, 600 }; 65 66 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | 67 WEBKIT_FIND_OPTIONS_WRAP_AROUND; 68 69 #define PROMPT_GO "Go:" 70 #define PROMPT_FIND "Find:" 71 72 /* SETPROP(readprop, setprop, prompt)*/ 73 #define SETPROP(r, s, p) { \ 74 .v = (const char *[]){ "/bin/sh", "-c", \ 75 "prop=\"$(printf '%b' \"$(xprop -id $1 "r" " \ 76 "| sed -e 's/^"r"(UTF8_STRING) = \"\\(.*\\)\"/\\1/' " \ 77 " -e 's/\\\\\\(.\\)/\\1/g')\" " \ 78 "| dmenu -p '"p"' -w $1)\" " \ 79 "&& xprop -id $1 -f "s" 8u -set "s" \"$prop\"", \ 80 "surf-setprop", winid, NULL \ 81 } \ 82 } 83 84 /* DOWNLOAD(URI, referer) */ 85 #define DOWNLOAD(u, r) { \ 86 .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\ 87 "cd ~/tmp && curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \ 88 " -e \"$3\" \"$4\"; read", \ 89 "surf-download", useragent, cookiefile, r, u, NULL \ 90 } \ 91 } 92 93 /* PLUMB(URI) */ 94 /* This called when some URI which does not begin with "about:", 95 * "http://" or "https://" should be opened. 96 */ 97 #define PLUMB(u) {\ 98 .v = (const char *[]){ "/bin/sh", "-c", \ 99 "xdg-open \"$0\"", u, NULL \ 100 } \ 101 } 102 103 /* PLUMBER(URI) */ 104 #define PLUMBER(u) {\ 105 .v = (const char *[]){ "/bin/sh", "-c", \ 106 "plumb \"$(echo $(xprop -id $0 $1 | cut -d '\"' -f2) )\"",\ 107 winid, u, NULL \ 108 } \ 109 } 110 111 /* VIDEOPLAY(URI) */ 112 #define VIDEOPLAY(u) {\ 113 .v = (const char *[]){ "/bin/sh", "-c", \ 114 "mpv --really-quiet \"$0\"", u, NULL \ 115 } \ 116 } 117 118 /* VIDEOPLAYTABBED(URI) */ 119 #define VIDEOPLAYTABBED(u) {\ 120 .v = (const char *[]){ "/bin/sh", "-c", "-x", \ 121 "mpv --really-quiet \"$(echo $(xprop -id $0 $1 | \ 122 cut -d '\"' -f2) )\"",\ 123 winid, u, NULL \ 124 } \ 125 } 126 127 /* BOOKMARK(URI) */ 128 #define BOOKMARKURI(r) {\ 129 .v = (const char *[]){ "st", "-e", "/bin/sh", "-c", "-x", \ 130 "bookmark \"$(echo $(xprop -id $0 $1) | cut -d '\"' -f2)\" " \ 131 "\"$(echo $(xprop -id $0 _NET_WM_NAME) | cut -d '\"' -f2 " \ 132 "| cut -d ' | ' -f3- )\" ",\ 133 winid, r, NULL \ 134 } \ 135 } 136 137 /* FIREFOX(URI) */ 138 #define FIREFOX(u) {\ 139 .v = (const char *[]){ "/bin/sh", "-c", \ 140 "firefox \"$(echo $(xprop -id $0 $1 | cut -d '\"' -f2) )\"",\ 141 winid, u, NULL \ 142 } \ 143 } 144 145 /* EDITSRC(URI) */ 146 #define EDITSRC(r) {\ 147 .v = (const char *[]){ "st", "-e", "/bin/sh", "-x", "-c", \ 148 "f=\"$(mktemp)\" && " \ 149 "curl -sL \"$(echo $(xprop -id $0 $1) | cut -d '\"' -f2)\" > \"$f\" && " \ 150 "tmux new-session \"$EDITOR '$f'\" ", \ 151 winid, r, NULL \ 152 } \ 153 } 154 155 /* styles */ 156 /* 157 * The iteration will stop at the first match, beginning at the beginning of 158 * the list. 159 */ 160 static SiteSpecific styles[] = { 161 /* regexp file in $styledir */ 162 { ".*", "default.css" }, 163 }; 164 165 /* certificates */ 166 /* 167 * Provide custom certificate for urls 168 */ 169 static SiteSpecific certs[] = { 170 /* regexp file in $certdir */ 171 { "://suckless\\.org/", "suckless.org.crt" }, 172 }; 173 174 #define MODKEY GDK_CONTROL_MASK 175 176 /* hotkeys */ 177 /* 178 * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to 179 * edit the CLEANMASK() macro. 180 */ 181 static Key keys[] = { 182 /* modifier keyval function arg */ 183 { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, 184 { 0, GDK_KEY_Escape, stop, { 0 } }, 185 { MODKEY, GDK_KEY_space, scrollv, { .i = +50 } }, 186 { MODKEY|GDK_SHIFT_MASK, XK_Next, zoom, { .i = -1 } }, 187 { MODKEY|GDK_SHIFT_MASK, XK_Prior, zoom, { .i = +1 } }, 188 { MODKEY|GDK_SHIFT_MASK, XK_Home, zoom, { .i = 0 } }, 189 190 { MODKEY, GDK_KEY_F11, togglefullscreen, { 0 } }, 191 192 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } }, 193 { MODKEY, GDK_KEY_b, spawn, BOOKMARKURI("_SURF_URI") }, 194 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } }, 195 { MODKEY, GDK_KEY_c, stop, { 0 } }, 196 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } }, 197 { MODKEY, GDK_KEY_d, scrollv, { .i = +50 } }, 198 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_d, scrollv, { .i = +100 } }, 199 { MODKEY, GDK_KEY_e, spawn, EDITSRC("_SURF_URI") }, 200 { MODKEY, GDK_KEY_f, spawn, FIREFOX("_SURF_URI") }, 201 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } }, 202 { MODKEY, GDK_KEY_h, navigate, { .i = -1 } }, 203 { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } }, 204 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } }, 205 { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } }, 206 { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } }, 207 { MODKEY, GDK_KEY_l, navigate, { .i = +1 } }, 208 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_l, toggle, { .i = Geolocation } }, 209 { MODKEY, GDK_KEY_m, spawn, VIDEOPLAYTABBED("_SURF_URI") }, 210 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } }, 211 { MODKEY, GDK_KEY_n, find, { .i = +1 } }, 212 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } }, 213 { MODKEY, GDK_KEY_o, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) }, 214 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } }, 215 { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } }, 216 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } }, 217 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } }, 218 { MODKEY, GDK_KEY_r, reload, { .i = 0 } }, 219 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } }, 220 { MODKEY, GDK_KEY_t, showcert, { 0 } }, 221 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } }, 222 { MODKEY, GDK_KEY_u, scrollv, { .i = -50 } }, 223 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_u, spawn, PLUMBER("_SURF_URI") }, 224 { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } }, 225 }; 226 227 /* button definitions */ 228 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */ 229 static Button buttons[] = { 230 /* target event mask button function argument stop event */ 231 { OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 }, 232 { OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 }, 233 { OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 }, 234 { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 }, 235 { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 }, 236 { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 }, 237 };