birdsurf

birdsurf - mrgrouse's fork of suckless' surf
Log | Files | Refs | README | LICENSE

config.def.h (8504B)


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