surf

My custom build of surf web browser.
git clone https://git.mtkn.jp/surf
Log | Files | Refs | README | LICENSE

config.def.h.orig (7641B)


      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 *styledir       = "~/.config/surf/styles/";
      5 static char *certdir        = "~/.cache/surf/certificates/";
      6 static char *cachedir       = "~/.cache/surf/cache/";
      7 static char *cookiefile     = "~/.cache/surf/cookies.txt";
      8 static char *scriptfiles[]  = {
      9 	"~/.config/surf/scripts/script.js",
     10 	"~/.config/surf/scripts/link_hints.js",
     11 	"~/.config/surf/scripts/easier_key.js",
     12 };
     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 	[AccessMicrophone]    =       { { .i = 0 },     },
     23 	[AccessWebcam]        =       { { .i = 0 },     },
     24 	[Certificate]         =       { { .i = 0 },     },
     25 	[CaretBrowsing]       =       { { .i = 0 },     },
     26 	[CookiePolicies]      =       { { .v = "@Aa" }, },
     27 	[DarkMode]            =       { { .i = 1 },     },
     28 	[DefaultCharset]      =       { { .v = "UTF-8" }, },
     29 	[DiskCache]           =       { { .i = 1 },     },
     30 	[DNSPrefetch]         =       { { .i = 0 },     },
     31 	[Ephemeral]           =       { { .i = 0 },     },
     32 	[FileURLsCrossAccess] =       { { .i = 0 },     },
     33 	[FontSize]            =       { { .i = 12 },    },
     34 	[FrameFlattening]     =       { { .i = 0 },     },
     35 	[Geolocation]         =       { { .i = 0 },     },
     36 	[HideBackground]      =       { { .i = 0 },     },
     37 	[Inspector]           =       { { .i = 0 },     },
     38 	[Java]                =       { { .i = 1 },     },
     39 	[JavaScript]          =       { { .i = 1 },     },
     40 	[KioskMode]           =       { { .i = 0 },     },
     41 	[LoadImages]          =       { { .i = 1 },     },
     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 /*
     59 	{ "(://|\\.)suckless\\.org(/|$)", {
     60 	  [JavaScript] = { { .i = 0 }, 1 },
     61 	}, },
     62 */
     63 };
     64 
     65 /* default window size: width, height */
     66 static int winsize[] = { 800, 600 };
     67 
     68 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
     69                                     WEBKIT_FIND_OPTIONS_WRAP_AROUND;
     70 
     71 #define PROMPT_GO   "Go:"
     72 #define PROMPT_FIND "Find:"
     73 
     74 /* SETPROP(readprop, setprop, prompt)*/
     75 #define SETPROP(r, s, p) { \
     76         .v = (const char *[]){ "/bin/sh", "-c", \
     77              "prop=\"$(printf '%b' \"$(xprop -id $1 "r" " \
     78              "| sed -e 's/^"r"(UTF8_STRING) = \"\\(.*\\)\"/\\1/' " \
     79              "      -e 's/\\\\\\(.\\)/\\1/g')\" " \
     80              "| dmenu -p '"p"' -w $1)\" " \
     81              "&& xprop -id $1 -f "s" 8u -set "s" \"$prop\"", \
     82              "surf-setprop", winid, NULL \
     83         } \
     84 }
     85 
     86 /* DOWNLOAD(URI, referer) */
     87 #define DOWNLOAD(u, r) { \
     88         .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
     89              "curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \
     90              " -e \"$3\" \"$4\"; read", \
     91              "surf-download", useragent, cookiefile, r, u, NULL \
     92         } \
     93 }
     94 
     95 /* PLUMB(URI) */
     96 /* This called when some URI which does not begin with "about:",
     97  * "http://" or "https://" should be opened.
     98  */
     99 #define PLUMB(u) {\
    100         .v = (const char *[]){ "/bin/sh", "-c", \
    101              "xdg-open \"$0\"", u, NULL \
    102         } \
    103 }
    104 
    105 /* VIDEOPLAY(URI) */
    106 #define VIDEOPLAY(u) {\
    107         .v = (const char *[]){ "/bin/sh", "-c", \
    108              "mpv --really-quiet \"$0\"", u, NULL \
    109         } \
    110 }
    111 
    112 /* styles */
    113 /*
    114  * The iteration will stop at the first match, beginning at the beginning of
    115  * the list.
    116  */
    117 static SiteSpecific styles[] = {
    118 	/* regexp               file in $styledir */
    119 	{ ".*",                 "default.css" },
    120 };
    121 
    122 /* certificates */
    123 /*
    124  * Provide custom certificate for urls
    125  */
    126 static SiteSpecific certs[] = {
    127 	/* regexp               file in $certdir */
    128 /*
    129 	{ "://suckless\\.org/", "suckless.org.crt" },
    130 */
    131 };
    132 
    133 #define MODKEY GDK_CONTROL_MASK
    134 
    135 /* hotkeys */
    136 /*
    137  * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
    138  * edit the CLEANMASK() macro.
    139  */
    140 static Key keys[] = {
    141 	/* modifier              keyval          function    arg */
    142 	{ MODKEY,                GDK_KEY_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
    143 	{ MODKEY,                GDK_KEY_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
    144 
    145 	{ MODKEY,                GDK_KEY_w,      playexternal, { 0 } },
    146 
    147 	{ MODKEY,                GDK_KEY_c,      stop,       { 0 } },
    148 
    149 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j,      zoom,       { .i = -1 } },
    150 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_k,      zoom,       { .i = +1 } },
    151 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_q,      zoom,       { .i = 0  } },
    152 	{ MODKEY,                GDK_KEY_minus,  zoom,       { .i = -1 } },
    153 	{ MODKEY,                GDK_KEY_plus,   zoom,       { .i = +1 } },
    154 
    155 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p,      clipboard,  { .i = 1 } },
    156 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_y,      clipboard,  { .i = 0 } },
    157 
    158 	{ MODKEY,                GDK_KEY_n,      find,       { .i = +1 } },
    159 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_n,      find,       { .i = -1 } },
    160 
    161 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p,      print,      { 0 } },
    162 	{ MODKEY,                GDK_KEY_t,      showcert,   { 0 } },
    163 
    164 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a,      togglecookiepolicy, { 0 } },
    165 	{ 0,                     GDK_KEY_F11,    togglefullscreen, { 0 } },
    166 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_o,      toggleinspector, { 0 } },
    167 
    168 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_c,      toggle,     { .i = CaretBrowsing } },
    169 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_f,      toggle,     { .i = FrameFlattening } },
    170 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_g,      toggle,     { .i = Geolocation } },
    171 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_s,      toggle,     { .i = JavaScript } },
    172 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_i,      toggle,     { .i = LoadImages } },
    173 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_b,      toggle,     { .i = ScrollBars } },
    174 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_t,      toggle,     { .i = StrictTLS } },
    175 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_m,      toggle,     { .i = Style } },
    176 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_d,      toggle,     { .i = DarkMode } },
    177 };
    178 
    179 /* button definitions */
    180 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
    181 static Button buttons[] = {
    182 	/* target       event mask      button  function        argument        stop event */
    183 	{ OnLink,       0,              2,      clicknewwindow, { .i = 0 },     1 },
    184 	{ OnLink,       MODKEY,         2,      clicknewwindow, { .i = 1 },     1 },
    185 	{ OnLink,       MODKEY,         1,      clicknewwindow, { .i = 1 },     1 },
    186 	{ OnAny,        0,              8,      clicknavigate,  { .i = -1 },    1 },
    187 	{ OnAny,        0,              9,      clicknavigate,  { .i = +1 },    1 },
    188 	{ OnMedia,      MODKEY,         1,      clickexternplayer, { 0 },       1 },
    189 };
    190 
    191 #define HOMEPAGE "https://duckduckgo.com/"