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