config.def.h (10719B)
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 *historyfile = "~/.surf/history.txt"; 10 static char *searchurl = "duckduckgo.com/?q=%s"; 11 static char *dldir = "~/dl/"; 12 static char *dlstatus = "~/.surf/dlstatus/"; 13 14 /* Webkit default features */ 15 /* Highest priority value will be used. 16 * Default parameters are priority 0 17 * Per-uri parameters are priority 1 18 * Command parameters are priority 2 19 */ 20 static Parameter defconfig[ParameterLast] = { 21 /* parameter Arg value priority */ 22 [AcceleratedCanvas] = { { .i = 1 }, }, 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 = 14 }, }, 33 [FrameFlattening] = { { .i = 0 }, }, 34 [Geolocation] = { { .i = 0 }, }, 35 [HideBackground] = { { .i = 0 }, }, 36 [Inspector] = { { .i = 0 }, }, 37 [Java] = { { .i = 1 }, }, 38 [JavaScript] = { { .i = 1 }, }, 39 [KioskMode] = { { .i = 0 }, }, 40 [LoadImages] = { { .i = 1 }, }, 41 [MediaManualPlay] = { { .i = 1 }, }, 42 [Plugins] = { { .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 [Plugins] = { { .i = 0 }, 1 }, 61 }, }, 62 }; 63 64 /* default window size: width, height */ 65 static int winsize[] = { 800, 600 }; 66 67 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | 68 WEBKIT_FIND_OPTIONS_WRAP_AROUND; 69 70 #define PROMPT_GO "Go:" 71 #define PROMPT_FIND "Find:" 72 73 /* SETPROP(readprop, setprop, prompt)*/ 74 #define SETPROP(r, s, p) { \ 75 .v = (const char *[]){ "/bin/sh", "-c", \ 76 "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \ 77 "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \ 78 "| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \ 79 "surf-setprop", winid, r, s, p, NULL \ 80 } \ 81 } 82 83 #define SEARCH() { \ 84 .v = (const char *[]){ "/bin/sh", "-c", \ 85 "xprop -id $1 -f $2 8s -set $2 \"" \ 86 "$(dmenu -p Search: -w $1 < /dev/null)\"", \ 87 "surf-search", winid, "_SURF_SEARCH", NULL \ 88 } \ 89 } 90 91 #define DLSTATUS { \ 92 .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\ 93 "while true; do cat $1/* 2>/dev/null || echo \"no hay descargas\";"\ 94 "A=; read A; "\ 95 "if [ $A = \"clean\" ]; then rm $1/*; fi; clear; done",\ 96 "surf-dlstatus", dlstatus, NULL } \ 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 117 #define SETURI(p) { .v = (char *[]){ "/bin/sh", "-c", \ 118 "prop=\"`surf_history_dmenu.sh`\" &&" \ 119 "xprop -id $1 -f $0 8s -set $0 \"$prop\"", \ 120 p, winid, NULL } } 121 122 123 #define ADDBMK { \ 124 .v = (char *[]){ "/bin/sh", "-c", \ 125 "bookmarkurl $0", winid, NULL \ 126 } \ 127 } 128 129 130 #define LOADBMK(r, s, p) { \ 131 .v = (const char *[]){ "/bin/sh", "-c", \ 132 "prop=\"$(loadbookmark $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \ 133 "surf-setprop", winid, r, s, p, NULL \ 134 } \ 135 } 136 137 /* styles */ 138 /* 139 * The iteration will stop at the first match, beginning at the beginning of 140 * the list. 141 */ 142 static SiteSpecific styles[] = { 143 /* regexp file in $styledir */ 144 { ".*", "default.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 static char *linkselect_curwin [] = { "/bin/sh", "-c", 157 "surf_linkselect.sh $0 'Link' | xargs -r xprop -id $0 -f _SURF_GO 8s -set _SURF_GO", 158 winid, NULL 159 }; 160 static char *linkselect_newtab [] = { "/bin/sh", "-c", 161 "surf_linkselect.sh $0 'Link (new window)' | xargs -r surf-open.sh", 162 winid, NULL 163 }; 164 static char *yanklink [] = { "/bin/sh", "-c", 165 "surf_linkselect.sh $0 'Yank Link to clipboard' | tr -d '\n' | xclip -selection clipboard", 166 winid, NULL 167 }; 168 static char *editscreen[] = { "/bin/sh", "-c", "edit_screen.sh", NULL }; 169 170 #define MODKEY GDK_CONTROL_MASK 171 172 /* hotkeys */ 173 /* 174 * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to 175 * edit the CLEANMASK() macro. 176 */ 177 static Key keys[] = { 178 /* modifier keyval function arg */ 179 { 0, GDK_KEY_o, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) }, 180 { 0, GDK_KEY_f, externalpipe, { .v = linkselect_curwin } }, 181 { 0|GDK_SHIFT_MASK, GDK_KEY_f, externalpipe, { .v = linkselect_newtab } }, 182 { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, 183 184 { 0, GDK_KEY_i, insert, { .i = 1 } }, 185 { 0, GDK_KEY_Escape, insert, { .i = 0 } }, 186 187 { 0, GDK_KEY_c, stop, { 0 } }, 188 189 { MODKEY, GDK_KEY_r, reload, { .i = 1 } }, 190 { 0, GDK_KEY_r, reload, { .i = 0 } }, 191 192 { 0|GDK_SHIFT_MASK, GDK_KEY_l, navigate, { .i = +1 } }, 193 { 0|GDK_SHIFT_MASK, GDK_KEY_h, navigate, { .i = -1 } }, 194 195 /* vertical and horizontal scrolling, in viewport per centage */ 196 { 0, GDK_KEY_j, scrollv, { .i = +10 } }, 197 { 0, GDK_KEY_k, scrollv, { .i = -10 } }, 198 { MODKEY, GDK_KEY_d, scrollv, { .i = +50 } }, 199 { MODKEY, GDK_KEY_u, scrollv, { .i = -50 } }, 200 { 0, GDK_KEY_i, insert, { .i = 1 } }, 201 { 0, GDK_KEY_Escape, insert, { .i = 0 } }, 202 203 204 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } }, 205 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } }, 206 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_h, zoom, { .i = 0 } }, 207 { 0, GDK_KEY_minus, zoom, { .i = -1 } }, 208 { 0|GDK_SHIFT_MASK, GDK_KEY_plus, zoom, { .i = +1 } }, 209 { 0, GDK_KEY_equal, zoom, { .i = 0 } }, 210 211 { 0, GDK_KEY_p, clipboard, { .i = 1 } }, 212 { 0, GDK_KEY_y, clipboard, { .i = 0 } }, 213 214 { 0, GDK_KEY_n, find, { .i = +1 } }, 215 { 0|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } }, 216 217 { MODKEY, GDK_KEY_p, print, { 0 } }, 218 { MODKEY, GDK_KEY_t, showcert, { 0 } }, 219 220 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } }, 221 { 0, GDK_KEY_F11, togglefullscreen, { 0 } }, 222 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } }, 223 224 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } }, 225 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } }, 226 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } }, 227 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } }, 228 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } }, 229 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } }, 230 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } }, 231 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } }, 232 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } }, 233 { MODKEY , GDK_KEY_Return, spawn, SETURI("_SURF_GO") }, 234 235 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_e, externalpipe, { .v = editscreen } }, 236 { MODKEY, GDK_KEY_y, externalpipe, { .v = yanklink } }, 237 { MODKEY, GDK_KEY_s, spawn, SEARCH() }, 238 { 0, GDK_KEY_m, spawn, ADDBMK }, 239 { 0|GDK_SHIFT_MASK, GDK_KEY_m, spawn, LOADBMK("_SURF_URI", "_SURF_GO", PROMPT_GO) }, 240 { MODKEY, GDK_KEY_w, playexternal, { 0 } }, 241 { 0|GDK_SHIFT_MASK, GDK_KEY_d, spawndls, { 0 } }, 242 }; 243 244 /* button definitions */ 245 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */ 246 static Button buttons[] = { 247 /* target event mask button function argument stop event */ 248 { OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 }, 249 { OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 }, 250 { OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 }, 251 { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 }, 252 { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 }, 253 { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 }, 254 }; 255 256 #define HOMEPAGE "https://duckduckgo.com/"