slackbuilds

Personal Slackbuilds in the style of slackbuilds.org
git clone git://git.danielmoch.com/slackbuilds.git
Log | Files | Refs

config.h (8374B)


      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     = "~/etc/surf/script.js";
      5 static char *styledir       = "~/etc/surf/styles/";
      6 static char *cachedir       = "~/etc/surf/cache/";
      7 static char *cookiefile     = "~/etc/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,         0),
     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,          0),
     34 	SETB(Style,              1),
     35 	SETF(ZoomLevel,          1.9),
     36 };
     37 
     38 static UriParameters uriparams[] = {
     39 	{ "(://|\\.)archlinux\\.org(/|$)",  { FSETB(JavaScript, 1), }, },
     40 	{ "(://|\\.)djmoch\\.org(/|$)",     { FSETB(JavaScript, 1), }, },
     41 	{ "(://|\\.)danielmoch\\.com(/|$)", { FSETB(JavaScript, 1), }, },
     42 	{ "(://|\\.)twitter\\.com(/|$)",    { FSETB(JavaScript, 1), }, },
     43 	{ "(://|\\.)github\\.com(/|$)",     { FSETB(JavaScript, 1), }, },
     44 	{ ".*",                             { FSETB(JavaScript, 0), }, },
     45 };
     46 
     47 static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
     48                                     WEBKIT_FIND_OPTIONS_WRAP_AROUND;
     49 
     50 #define SETPROP(p, q) { \
     51         .v = (const char *[]){ "/bin/sh", "-c", \
     52              "prop=\"`xprop -id $2 $0 " \
     53              "| sed \"s/^$0(STRING) = \\(\\\\\"\\?\\)\\(.*\\)\\1$/\\2/\" " \
     54              "| xargs -0 printf %b | dmenu -fn \"sans:size=9\" -nb \"#3A3A3A\" " \
     55 	     "-nf \"#FFFFFF\" -sb \"#BCBCBC\" -sf \"#000000\"`\" &&" \
     56              "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
     57              p, q, winid, NULL \
     58         } \
     59 }
     60 
     61 #define SEARCH(p, q) { \
     62         .v = (const char *[]){ "/bin/sh", "-c", \
     63              "prop=\"https://duckduckgo.com/html?q=`dmenu -p \"Search DuckDuckGo\" " \
     64              "-fn \"sans:size=9\" -nb \"#3A3A3A\" " \
     65 	     "-nf \"#FFFFFF\" -sb \"#BCBCBC\" -sf \"#000000\"`\" &&" \
     66              "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
     67              p, q, winid, NULL \
     68         } \
     69 }
     70 
     71 #define BMARK(p, q) { \
     72         .v = (const char *[]){ "/bin/sh", "-c", \
     73              "prop=\"`cat ~/etc/surf/bookmarks " \
     74              "| dmenu -fn \"sans:size=9\" -nb \"#3A3A3A\" " \
     75 	     "-nf \"#FFFFFF\" -sb \"#BCBCBC\" -sf \"#000000\"`\" &&" \
     76              "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
     77              p, q, winid, NULL \
     78         } \
     79 }
     80 
     81 #define BMARKSAVE(p, q) { \
     82         .v = (const char *[]){ "/bin/sh", "-c", \
     83              "prop=\"`xprop -id $2 $0 " \
     84              "| sed \"s/^$0(STRING) = \\(\\\\\"\\?\\)\\(.*\\)\\1$/\\2/\" " \
     85              "| xargs printf %b\n`\" && echo \"$prop\" >> ~/etc/surf/bookmarks", \
     86              p, q, winid, NULL \
     87         } \
     88 }
     89 
     90 /* DOWNLOAD(URI, referer) */
     91 #define DOWNLOAD(d, r) { \
     92         .v = (const char *[]){ "/bin/sh", "-c", \
     93              "my term -e /bin/sh -c \"cd ~/dl; curl -g -L -J -O " \
     94 	     "--user-agent '$1' --referer '$2' -b $3 -c $3 '$0';" \
     95              " sleep 5;\"", \
     96              d, useragent, r, cookiefile, NULL \
     97         } \
     98 }
     99 
    100 /* PLUMB(URI) */
    101 /* This called when some URI which does not begin with "about:",
    102  * "http://" or "https://" should be opened.
    103  */
    104 #define PLUMB(u) {\
    105         .v = (const char *[]){ "/bin/sh", "-c", \
    106              "xdg-open \"$0\"", u, NULL \
    107         } \
    108 }
    109 
    110 /* VIDEOPLAY(URI) */
    111 #define VIDEOPLAY(u) {\
    112         .v = (const char *[]){ "/bin/sh", "-c", \
    113              "mplayer --really-quiet \"$0\"", u, NULL \
    114         } \
    115 }
    116 
    117 /* styles */
    118 /*
    119  * The iteration will stop at the first match, beginning at the beginning of
    120  * the list.
    121  */
    122 static SiteStyle styles[] = {
    123 	/* regexp               file in $styledir */
    124 	{ ".*",                 "default.css" },
    125 };
    126 
    127 #define MODKEY GDK_CONTROL_MASK
    128 
    129 /* hotkeys */
    130 /*
    131  * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
    132  * edit the CLEANMASK() macro.
    133  */
    134 static Key keys[] = {
    135 	/* modifier              keyval          function    arg */
    136 	{ MODKEY,                GDK_KEY_g,      spawn,      SETPROP("_SURF_URI", "_SURF_GO") },
    137 	{ MODKEY,                GDK_KEY_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
    138 	{ MODKEY,                GDK_KEY_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND") },
    139 	{ MODKEY,                GDK_KEY_s,      spawn,      SEARCH("_SURF_URI", "_SURF_GO") },
    140 	{ MODKEY,                GDK_KEY_d,      spawn,      BMARK("_SURF_URI", "_SURF_GO") },
    141 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_d,      spawn,      BMARKSAVE("_SURF_URI", "_SURF_GO") },
    142 
    143 	{ 0,                     GDK_KEY_Escape, stop,       { 0 } },
    144 	{ MODKEY,                GDK_KEY_c,      stop,       { 0 } },
    145 
    146 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_r,      reload,     { .b = 1 } },
    147 	{ MODKEY,                GDK_KEY_r,      reload,     { .b = 0 } },
    148 
    149 	{ MODKEY,                GDK_KEY_l,      navigate,   { .i = +1 } },
    150 	{ MODKEY,                GDK_KEY_h,      navigate,   { .i = -1 } },
    151 
    152 	/* Currently we have to use scrolling steps that WebKit2GTK+ gives us
    153 	 * d: step down, u: step up, r: step right, l:step left
    154 	 * D: page down, U: page up */
    155 	{ MODKEY,                GDK_KEY_j,      scroll,     { .i = 'd' } },
    156 	{ MODKEY,                GDK_KEY_k,      scroll,     { .i = 'u' } },
    157 	{ MODKEY,                GDK_KEY_b,      scroll,     { .i = 'U' } },
    158 	{ MODKEY,                GDK_KEY_space,  scroll,     { .i = 'D' } },
    159 	{ MODKEY,                GDK_KEY_i,      scroll,     { .i = 'r' } },
    160 	{ MODKEY,                GDK_KEY_u,      scroll,     { .i = 'l' } },
    161 
    162 
    163 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j,      zoom,       { .i = -1 } },
    164 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_k,      zoom,       { .i = +1 } },
    165 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_q,      zoom,       { .i = 0  } },
    166 	{ MODKEY,                GDK_KEY_minus,  zoom,       { .i = -1 } },
    167 	{ MODKEY,                GDK_KEY_plus,   zoom,       { .i = +1 } },
    168 
    169 	{ MODKEY,                GDK_KEY_p,      clipboard,  { .b = 1 } },
    170 	{ MODKEY,                GDK_KEY_y,      clipboard,  { .b = 0 } },
    171 
    172 	{ MODKEY,                GDK_KEY_n,      find,       { .i = +1 } },
    173 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_n,      find,       { .i = -1 } },
    174 
    175 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p,      print,      { 0 } },
    176 
    177 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a,      togglecookiepolicy, { 0 } },
    178 	{ 0,                     GDK_KEY_F11,    togglefullscreen, { 0 } },
    179 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_o,      toggleinspector, { 0 } },
    180 
    181 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_c,      toggle,     { .i = CaretBrowsing } },
    182 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_f,      toggle,     { .i = FrameFlattening } },
    183 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_g,      toggle,     { .i = Geolocation } },
    184 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_s,      toggle,     { .i = JavaScript } },
    185 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_i,      toggle,     { .i = LoadImages } },
    186 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_v,      toggle,     { .i = Plugins } },
    187 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_b,      toggle,     { .i = ScrollBars } },
    188 	{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_m,      toggle,     { .i = Style } },
    189 };
    190 
    191 /* button definitions */
    192 /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
    193 static Button buttons[] = {
    194 	/* target       event mask      button  function        argument        stop event */
    195 	{ OnLink,       0,              2,      clicknewwindow, { .b = 0 },     1 },
    196 	{ OnLink,       MODKEY,         2,      clicknewwindow, { .b = 1 },     1 },
    197 	{ OnLink,       MODKEY,         1,      clicknewwindow, { .b = 1 },     1 },
    198 	{ OnAny,        0,              8,      clicknavigate,  { .i = -1 },    1 },
    199 	{ OnAny,        0,              9,      clicknavigate,  { .i = +1 },    1 },
    200 	{ OnMedia,      MODKEY,         1,      clickexternplayer, { 0 },       1 },
    201 };