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