surf

surf browser, a WebKit based browser
git clone git://git.suckless.org/surf
Log | Files | Refs | README | LICENSE

config.def.h (8189B)


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