dotfiles

My dotfiles for Arch Linux
Log | Files | Refs | README

config.h (7577B)


      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 *cachedir       = "~/.surf/cache/";
      7 static char *cookiefile     = "~/.surf/cookies.txt";
      8 
      9 /* Webkit default features */
     10 static Parameter defconfig[ParameterLast] = {
     11 	SETB(AcceleratedCanvas,  1),
     12 	SETB(CaretBrowsing,      0),
     13 	SETV(CookiePolicies,     "@Aa"),
     14 	SETB(DiskCache,          1),
     15 	SETB(DNSPrefetch,        0),
     16 	SETI(FontSize,           14),
     17 	SETB(FrameFlattening,    0),
     18 	SETB(Geolocation,        0),
     19 	SETB(HideBackground,     0),
     20 	SETB(Inspector,          0),
     21 	SETB(JavaScript,         1),
     22 	SETB(KioskMode,          0),
     23 	SETB(LoadImages,         1),
     24 	SETB(MediaManualPlay,    0),
     25 	SETB(Plugins,            1),
     26 	SETV(PreferredLanguages, ((char *[]){ NULL })),
     27 	SETB(RunInFullscreen,    0),
     28 	SETB(ScrollBars,         1),
     29 	SETB(ShowIndicators,     1),
     30 	SETB(SiteQuirks,         1),
     31 	SETB(SpellChecking,      0),
     32 	SETV(SpellLanguages,     ((char *[]){ "en_US", NULL })),
     33 	SETB(StrictSSL,          1),
     34 	SETB(Style,              1),
     35 	SETF(ZoomLevel,          1.5),
     36 };
     37 
     38 static UriParameters uriparams[] = {
     39 	{ "", {
     40 	  FSETB(JavaScript, 0),
     41 	  FSETB(Plugins,    0),
     42 	}, },
     43 };
     44 
     45 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
     46                                     WEBKIT_FIND_OPTIONS_WRAP_AROUND;
     47 
     48 #define SETPROP(p, q) { \
     49         .v = (const char *[]){ "/bin/sh", "-c", \
     50              "prop=\"`xprop -id $2 $0 " \
     51              "| sed \"s/^$0(STRING) = \\(\\\\\"\\?\\)\\(.*\\)\\1$/\\2/\" " \
     52              "| xargs -0 printf %b | dmenu -p 'Open URL:' -l 1 -fn 'Sans:size=12:weight=bold'`\" &&" \
     53              "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
     54              p, q, winid, NULL \
     55         } \
     56 }
     57 
     58 /* DOWNLOAD(URI, referer) */
     59 #define DOWNLOAD(d, r) { \
     60         .v = (const char *[]){ "/bin/sh", "-c", \
     61              "st -e /bin/sh -c \"curl -g -L -J -O --user-agent '$1'" \
     62              " --referer '$2' -b $3 -c $3 '$0';" \
     63              " sleep 5;\"", \
     64              d, useragent, r, cookiefile, NULL \
     65         } \
     66 }
     67 
     68 /* PLUMB(URI) */
     69 /* This called when some URI which does not begin with "about:",
     70  * "http://" or "https://" should be opened.
     71  */
     72 #define PLUMB(u) {\
     73         .v = (const char *[]){ "/bin/sh", "-c", \
     74              "xdg-open \"$0\"", u, NULL \
     75         } \
     76 }
     77 
     78 /* VIDEOPLAY(URI) */
     79 #define VIDEOPLAY(u) {\
     80         .v = (const char *[]){ "/bin/sh", "-c", \
     81              "mpv --really-quiet \"$0\"", u, NULL \
     82         } \
     83 }
     84 
     85 /* styles */
     86 /*
     87  * The iteration will stop at the first match, beginning at the beginning of
     88  * the list.
     89  */
     90 static SiteStyle styles[] = {
     91 	/* regexp               file in $styledir */
     92 	{ ".*",                 "default.css" },
     93 };
     94 
     95 #define MODKEY GDK_CONTROL_MASK
     96 
     97 #define ADDBMK { \
     98 	.v = (char *[]){ "/bin/sh", "-c", \
     99 	     "surf_bookmarkurl $0", winid, NULL \
    100 	} \
    101 }
    102 
    103 #define LOADBMK(r, s, p) { \
    104 	.v = (const char *[]){ "/bin/sh", "-c", \
    105 	     "prop=\"$(surf_loadbookmark $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
    106 	     "surf-setprop", winid, r, s, p, NULL \
    107 	} \
    108 }
    109 /* hotkeys */
    110 /*
    111  * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
    112  * edit the CLEANMASK() macro.
    113  */
    114 static Key keys[] = {
    115 	/* modifier              keyval          function    arg */
    116 	{ MODKEY,                GDK_KEY_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO") },
    117 	{ MODKEY,                GDK_KEY_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
    118 
    119 	{ MODKEY,                GDK_KEY_c,      stop,     { 0 } },
    120 
    121 	{ MODKEY,                GDK_KEY_r,      reload,   { .i = 1 } },
    122 	{ MODKEY,                GDK_KEY_r,      reload,   { .i = 0 } },
    123 
    124 	{ MODKEY,                GDK_KEY_l,      navigate,   { .i = +1 } },
    125 	{ MODKEY,                GDK_KEY_h,      navigate,   { .i = -1 } },
    126 
    127 	/* Currently we have to use scrolling steps that WebKit2GTK+ gives us
    128 	 * d: step down, u: step up, r: step right, l:step left
    129 	 * D: page down, U: page up */
    130 	{ MODKEY,                GDK_KEY_j,      scroll,     { .i = 'd' } },
    131 	{ MODKEY,                GDK_KEY_k,      scroll,     { .i = 'u' } },
    132 	{ MODKEY,                GDK_KEY_u,      scroll,     { .i = 'U' } },
    133 	{ MODKEY,                GDK_KEY_space,  scroll,     { .i = 'D' } },
    134 	{ MODKEY,                GDK_KEY_o,      scroll,     { .i = 'r' } },
    135 	{ MODKEY,                GDK_KEY_i,      scroll,     { .i = 'l' } },
    136 
    137 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_equal,  zoom,       { .i = 0  } },
    138 	{ MODKEY,                GDK_KEY_minus,  zoom,       { .i = -1 } },
    139 	{ MODKEY,                GDK_KEY_plus,   zoom,       { .i = +1 } },
    140 
    141 	{ MODKEY,                GDK_KEY_p,      clipboard,  { .b = 1 } },
    142 	{ MODKEY,                GDK_KEY_y,      clipboard,  { .b = 0 } },
    143 
    144 	{ MODKEY,                GDK_KEY_n,      find,       { .i = +1 } },
    145 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_n,      find,       { .i = -1 } },
    146 
    147 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p,      print,      { 0 } },
    148 
    149 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a,      togglecookiepolicy, { 0 } },
    150 	{ MODKEY,                GDK_KEY_F11,    togglefullscreen, { 0 } },
    151 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_o,      toggleinspector, { 0 } },
    152 
    153 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_c,      toggle,     { .i = CaretBrowsing } },
    154 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_f,      toggle,     { .i = FrameFlattening } },
    155 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_g,      toggle,     { .i = Geolocation } },
    156 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_s,      toggle,     { .i = JavaScript } },
    157 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_i,      toggle,     { .i = LoadImages } },
    158 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_v,      toggle,     { .i = Plugins } },
    159 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_x,      toggle,     { .i = ScrollBars } },
    160 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_m,      toggle,     { .i = Style } },
    161 	{ MODKEY,                GDK_KEY_b,      spawn,      LOADBMK("_SURF_URI", "_SURF_GO", "PROMPT_GO") },
    162         { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b,      spawn,      ADDBMK },
    163 
    164 
    165 };
    166 
    167 /* button definitions */
    168 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
    169 static Button buttons[] = {
    170 	/* target       event mask      button  function        argument        stop event */
    171 	{ OnLink,       0,              2,      clicknewwindow, { .b = 0 },     1 },
    172 	{ OnLink,       MODKEY,         2,      clicknewwindow, { .b = 1 },     1 },
    173 	{ OnLink,       MODKEY,         1,      clicknewwindow, { .b = 1 },     1 },
    174 	{ OnAny,        0,              8,      clicknavigate,  { .i = -1 },    1 },
    175 	{ OnAny,        0,              9,      clicknavigate,  { .i = +1 },    1 },
    176 	{ OnMedia,      MODKEY,         1,      clickexternplayer, { 0 },       1 },
    177 };
    178 
    179 /* Custom content */
    180 static SearchEngine searchengines[] = {
    181 	{ "d",       "https://duckduckgo.com/?q=%s"                                       },
    182 	{ "g",       "https://www.google.de/search?q=%s"                                  },
    183 	{ "linguee", "https://www.linguee.com/english-german/search?source=auto&query=%s" },
    184 	{ "dict",    "https://www.dict.cc/?s=%s"                                          },
    185 	{ "leo",     "https://dict.leo.org/ende?search=%s"                                },
    186 	{ "y",       "https://youtube.com/results?search_query=%s"                        },
    187 	{ "wen",     "https://en.wikipedia.org/wiki/%s"                                   },
    188 	{ "wde",     "https://de.wikipedia.org/wiki/%s"                                   },
    189 };