surf

Surf web browser.
git clone git://r-36.net/surf
Log | Files | Refs | README | LICENSE

config.def.h (9673B)


      1 /* Welcome to Surf! */
      2 
      3 /* Path configuration */
      4 static char *scriptfile     = "~/.surf/script.js";
      5 static char *styledir       = "~/.surf/styles/";
      6 static char *cachefolder    = "~/.surf/cache/";
      7 static char *dbfolder       = "~/.surf/databases/";
      8 
      9 /* visual options */
     10 static Bool kioskmode       = FALSE; /* Ignore shortcuts */
     11 static Bool showindicators  = TRUE;  /* Show indicators in window title */
     12 static Bool zoomto96dpi     = TRUE;  /* Zoom pages to always emulate 96dpi */
     13 static Bool runinfullscreen = FALSE; /* Run in fullscreen mode by default */
     14 static Bool accelrendering  = TRUE;  /* Allow accelerated compositing of
     15 				      *	the page, using the GPU, if available. */
     16 
     17 static char *defaultencoding     = "utf-8"; /* Default encoding for files. */
     18 static guint defaultfontsize     = 12;      /* Default font size */
     19 static guint defaultmonofontsize = 10;   /* Default monospace font size */
     20 static gfloat zoomlevel          = 1.0;     /* Default zoom level */
     21 
     22 /* Soup default features */
     23 static char *cookiefile     = "~/.surf/cookies.txt";
     24 static char *cookiepolicies = "Aa@"; /* A: accept all; a: accept nothing,
     25                                         @: accept all except third party */
     26 static char *cafile         = "/etc/ssl/certs/ca-certificates.crt";
     27 static Bool strictssl       = TRUE; /* strict means if untrusted SSL/TLS
     28 				     * connections should be refused. */
     29 static time_t sessiontime   = 3600;
     30 static Bool enablediskcache = TRUE;
     31 static int diskcachebytes   = 5 * 1024 * 1024;
     32 #define uafile                "~/.surf/useragents.txt"
     33 
     34 /* Webkit default features */
     35 static Bool enablescrollbars      = TRUE;
     36 static Bool enablespatialbrowsing = TRUE;
     37 static Bool enablespellchecking   = FALSE;
     38 static Bool enableplugins         = TRUE;
     39 static Bool enablepagecache       = TRUE; /* Enable cache of pages in current
     40 					   * history. This will save memory
     41 					   * if you do not have any. */
     42 static Bool privatebrowsing       = FALSE; /* Set default value for private
     43 					    * browsing. */
     44 static Bool enablescripts         = TRUE;
     45 static Bool enableinspector       = TRUE;
     46 static Bool enablestyle           = TRUE;
     47 static Bool enablehtml5db         = TRUE;
     48 static Bool enablehtml5local      = TRUE;
     49 static Bool enablejava            = FALSE; /* Toggle if <applet> is allowed. */
     50 static Bool enablemediastream     = FALSE; /* Allow access to local video
     51 					    * and audio input devices. */
     52 static Bool enablemediasource     = FALSE; /* Allow JS to generate media
     53 					    * streams. */
     54 static Bool enablewebaudio        = FALSE; /* Allow JS to generate wav
     55 					    * streams. */
     56 static Bool inlineplayback        = TRUE;  /* Toggle if media should be played
     57 					    * inline. */
     58 static Bool inlinegestures        = TRUE;  /* Toggle if media playbeck
     59 					    * requires some click to start. */
     60 static Bool enablewebgl           = TRUE;
     61 static Bool dnsprefetching        = FALSE; /* DNS prefetching is insecure,
     62 					    * so disabled. */
     63 static Bool offlineappcache       = FALSE; /* Allow offline web application
     64 					    * cache? NO! */
     65 static Bool loadimages            = TRUE;
     66 static Bool hidebackground        = FALSE;
     67 static Bool allowgeolocation      = TRUE;
     68 static Bool insecureresources     = FALSE; /* Whether to allow to load
     69 					    * non-HTTPS resources in HTTPS pages. */
     70 
     71 /*
     72  * Now on TV: »What is the best User-Agent for me?«
     73  * Result: None.
     74  */
     75 char *useragent = " ";
     76 /*
     77  * These are for the case some incompetent »web programmer« decided for you
     78  * what is best for you.
     79  */
     80 /*
     81 static char *useragent      = "Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) "
     82         "Gecko/41.0 Firefox/41.0";
     83 static char *useragent      = "Mozilla/5.0 (X11; Linux x86_64) "
     84         "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.19 "
     85 	"Safari/537.36";
     86 static char *useragent      = "Mozilla/5.0 (X11; U; Unix; en-US) "
     87 	"AppleWebKit/537.15 (KHTML, like Gecko) Chrome/24.0.1295.0 "
     88 	"Safari/537.15 Surf/"VERSION;
     89 */
     90 
     91 /* custom http headers */
     92 static HttpHeader customheaders[] = {
     93 	/* key, value */
     94 	/* Do-Not-Track. Haha! */
     95 	{ "DNT", "1" },
     96 	/* We are a damn US imperialist. Change to cn, once Chinese communism
     97 	 * has won.*/
     98 	{ "Accept-Language", "en-US,en;q=0.5" },
     99 	{ "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" },
    100 	{ "Accept-Encoding", "gzip, deflate" },
    101 	/* We are ready for TLS. Is it still secure? */
    102 	{ "Upgrade-Insecure-Requests", "1" },
    103 };
    104 
    105 #define PROMPT_GOTO  "Go To"
    106 #define PROMPT_FIND  "Find"
    107 #define PROMPT_SLASH "/"
    108 #define PROMPT_UA    "Set User-Agent"
    109 
    110 /* Set the property of surf using the old value. */
    111 #define SETPROP(p, q, prompt) { \
    112 	.v = (char *[]){ "/bin/sh", "-c", \
    113 		"prop=\"`xprop -id $2 $0 " \
    114 		"| sed \"s/^$0([A-Z0-9_]*) = \\(\\\\\"\\?\\)\\(.*\\)\\1$/\\2/\" " \
    115 		"| xargs -0 printf %b | dmenu -p \"$3\"`\" &&" \
    116 		"xprop -id $2 -f $1 8u -set $1 \"$prop\"", \
    117 		p, q, winid, prompt, NULL \
    118 	} \
    119 }
    120 
    121 /*
    122  * Set the property of surf using the old value and values supplied from a
    123  * file.
    124  */
    125 #define SETPROPFROMFILE(p, q, prompt, file) { \
    126 	.v = (char *[]){ "/bin/bash", "-c", \
    127 		"prop=\"`{ xprop -id $2 $0 " \
    128 		"| sed \"s/^$0([0-9A-Z_]*) = \\(\\\\\"\\?\\)\\(.*\\)\\1$/\\2/\" " \
    129 		"| xargs -0 printf %b; " \
    130 		"  [ -e $(eval echo $4) ] && cat $(eval echo $4); } " \
    131 		"| dmenu -p \"$3\"`\" &&" \
    132 		"xprop -id $2 -f $1 8u -set $1 \"$prop\"", \
    133 		p, q, winid, prompt, file, NULL \
    134 	} \
    135 }
    136 
    137 /* DOWNLOAD(URI, referer) */
    138 #define DOWNLOAD(d, r) { \
    139 	.v = (char *[]){ "/bin/sh", "-c", \
    140 		"/bin/sh -c \"download '$1' '$2' '$3' '$0'\"", \
    141 		d, useragent, r, cookiefile, NULL \
    142 	} \
    143 }
    144 
    145 /* PLUMB(URI) */
    146 /* This called when some URI which does not begin with "about:",
    147  * "http://" or "https://" should be opened.
    148  */
    149 #define PLUMB(u) {\
    150 	.v = (char *[]){ "/bin/sh", "-c", \
    151 		"plumb \"$0\"", u, NULL \
    152 	} \
    153 }
    154 
    155 /* styles */
    156 /*
    157  * The iteration will stop at the first match, beginning at the beginning of
    158  * the list.
    159  */
    160 static SiteStyle styles[] = {
    161 	/* regexp		file in $styledir */
    162 	{ ".*",			"default.css" },
    163 };
    164 
    165 #define MODKEY GDK_CONTROL_MASK
    166 
    167 /* hotkeys */
    168 /*
    169  * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
    170  * edit the CLEANMASK() macro.
    171  */
    172 static Key keys[] = {
    173 	/* modifier	            keyval      function    arg             Focus */
    174 	{ MODKEY|GDK_SHIFT_MASK,GDK_r,      reload,     { .b = TRUE } },
    175 	{ MODKEY,               GDK_r,      reload,     { .b = FALSE } },
    176 	{ MODKEY|GDK_SHIFT_MASK,GDK_p,      print,      { 0 } },
    177 
    178 	{ MODKEY,               GDK_p,      clipboard,  { .b = TRUE } },
    179 	{ MODKEY,               GDK_y,      clipboard,  { .b = FALSE } },
    180 
    181 	{ MODKEY|GDK_SHIFT_MASK,GDK_j,      zoom,       { .i = -1 } },
    182 	{ MODKEY|GDK_SHIFT_MASK,GDK_k,      zoom,       { .i = +1 } },
    183 	{ MODKEY|GDK_SHIFT_MASK,GDK_q,      zoom,       { .i = 0  } },
    184 	{ MODKEY,               GDK_minus,  zoom,       { .i = -1 } },
    185 	{ MODKEY,               GDK_plus,   zoom,       { .i = +1 } },
    186 
    187 	{ MODKEY|GDK_SHIFT_MASK,GDK_l,      toggleinsecurecontent, { 0 } },
    188 	{ MODKEY,               GDK_l,      navigate,   { .i = +1 } },
    189 	{ MODKEY,               GDK_h,      navigate,   { .i = -1 } },
    190 
    191 	{ MODKEY,               GDK_j,      scroll_v,   { .i = +1 } },
    192 	{ MODKEY,               GDK_k,      scroll_v,   { .i = -1 } },
    193 	{ MODKEY,               GDK_b,      scroll_v,   { .i = -10000 } },
    194 	{ MODKEY,               GDK_space,  scroll_v,   { .i = +10000 } },
    195 	{ MODKEY,               GDK_i,      scroll_h,   { .i = +1 } },
    196 	{ MODKEY,               GDK_u,      scroll_h,   { .i = -1 } },
    197 
    198 	{ 0,                    GDK_F11,    fullscreen, { 0 } },
    199 	{ 0,                    GDK_Escape, stop,       { 0 } },
    200 	{ MODKEY,               GDK_o,      source,     { 0 } },
    201 	{ MODKEY|GDK_SHIFT_MASK,GDK_o,      inspector,  { 0 } },
    202 
    203 	{ MODKEY,               GDK_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GOTO) },
    204 	{ MODKEY,               GDK_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
    205 	{ MODKEY,               GDK_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_SLASH) },
    206 	{ MODKEY,               GDK_a,      spawn,      SETPROPFROMFILE("_SURF_UA", "_SURF_UA", PROMPT_UA, uafile) },
    207 
    208 	{ MODKEY,               GDK_n,      find,       { .b = TRUE } },
    209 	{ MODKEY|GDK_SHIFT_MASK,GDK_n,      find,       { .b = FALSE } },
    210 
    211 	{ MODKEY|GDK_SHIFT_MASK,GDK_c,      toggle,     { .v = "enable-caret-browsing" } },
    212 	{ MODKEY|GDK_SHIFT_MASK,GDK_i,      toggle,     { .v = "auto-load-images" } },
    213 	{ MODKEY|GDK_SHIFT_MASK,GDK_s,      toggle,     { .v = "enable-scripts" } },
    214 	{ MODKEY|GDK_SHIFT_MASK,GDK_v,      toggle,     { .v = "enable-plugins" } },
    215 	{ MODKEY|GDK_SHIFT_MASK,GDK_t,      togglesoup, { .v = "ssl-strict" } },
    216 	{ MODKEY|GDK_SHIFT_MASK,GDK_w,      toggle,     { .v = "enable-private-browsing" } },
    217 	{ MODKEY|GDK_SHIFT_MASK,GDK_a,      togglecookiepolicy, { 0 } },
    218 	{ MODKEY|GDK_SHIFT_MASK,GDK_m,      togglestyle, { 0 } },
    219 	{ MODKEY|GDK_SHIFT_MASK,GDK_b,      togglescrollbars, { 0 } },
    220 	{ MODKEY|GDK_SHIFT_MASK,GDK_g,      togglegeolocation, { 0 } },
    221 	{ MODKEY|GDK_SHIFT_MASK,GDK_y,      toggleproxy, { 0 } },
    222 };
    223 
    224 /* button definitions */
    225 /* click can be ClkDoc, ClkLink, ClkImg, ClkMedia, ClkSel, ClkEdit, ClkAny */
    226 static Button buttons[] = {
    227 	/* click                event mask  button  function        argument */
    228 	{ ClkLink,              0,          2,      linkopenembed,  { 0 } },
    229 	{ ClkLink,              MODKEY,     2,      linkopen,       { 0 } },
    230 	{ ClkLink,              MODKEY,     1,      linkopen,       { 0 } },
    231 	{ ClkAny,               0,          8,      navigate,       { .i = -1 } },
    232 	{ ClkAny,               0,          9,      navigate,       { .i = +1 } },
    233 };
    234