spacepaste

  1.  
  2. /* modifier 0 means no modifier */
  3. static int surfuseragent = 1; /* Append Surf version to default WebKit user agent */
  4. static char *fulluseragent = ""; /* Or override the whole user agent string */
  5. static char *scriptfile = "~/.surf/script.js";
  6. static char *styledir = "~/.surf/styles/";
  7. static char *cachedir = "~/.surf/cache/";
  8. static char *cookiefile = "~/.surf/cookies.txt";
  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, 12),
  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, 0),
  34. SETB(Style, 1),
  35. SETF(ZoomLevel, 1.0),
  36. };
  37. static UriParameters uriparams[] = {
  38. { "(://|\\.)suckless\\.org(/|$)", {
  39. FSETB(JavaScript, 0),
  40. FSETB(Plugins, 0),
  41. }, },
  42. };
  43. static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
  44. WEBKIT_FIND_OPTIONS_WRAP_AROUND;
  45. #define SETPROP(p, q) { \
  46. .v = (const char *[]){ "/bin/sh", "-c", \
  47. "prop=\"`xprop -id $2 $0 " \
  48. "| sed \"s/^$0(STRING) = \\(\\\\\"\\?\\)\\(.*\\)\\1$/\\2/\" " \
  49. "| xargs -0 printf %b | dmenu`\" &&" \
  50. "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
  51. p, q, winid, NULL \
  52. } \
  53. }
  54. /* DOWNLOAD(URI, referer) */
  55. #define DOWNLOAD(d, r) { \
  56. .v = (const char *[]){ "/bin/sh", "-c", \
  57. "st -e /bin/sh -c \"curl -g -L -J -O --user-agent '$1'" \
  58. " --referer '$2' -b $3 -c $3 '$0';" \
  59. " sleep 5;\"", \
  60. d, useragent, r, cookiefile, NULL \
  61. } \
  62. }
  63. /* PLUMB(URI) */
  64. /* This called when some URI which does not begin with "about:",
  65. * "http://" or "https://" should be opened.
  66. */
  67. #define PLUMB(u) {\
  68. .v = (const char *[]){ "/bin/sh", "-c", \
  69. "xdg-open \"$0\"", u, NULL \
  70. } \
  71. }
  72. /* VIDEOPLAY(URI) */
  73. #define VIDEOPLAY(u) {\
  74. .v = (const char *[]){ "/bin/sh", "-c", \
  75. "mpv --really-quiet \"$0\"", u, NULL \
  76. } \
  77. }
  78. #define WATCH {.v = (char *[]){ "/bin/sh", "-c", \
  79. "st -e \
  80. yt $(xprop -id $0 _SURF_URI | cut -d \\\" -f 2)", \
  81. winid, NULL } }
  82. /* styles */
  83. /*
  84. * The iteration will stop at the first match, beginning at the beginning of
  85. * the list.
  86. */
  87. static SiteStyle styles[] = {
  88. /* regexp file in $styledir */
  89. { ".*", "default.css" },
  90. };
  91. #define MODKEY GDK_CONTROL_MASK
  92. /* hotkeys */
  93. /*
  94. * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
  95. * edit the CLEANMASK() macro.
  96. */
  97. static Key keys[] = {
  98. /* modifier keyval function arg */
  99. { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") },
  100. { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
  101. { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
  102. { 0, GDK_KEY_Escape, stop, { 0 } },
  103. { MODKEY, GDK_KEY_c, stop, { 0 } },
  104. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .b = 1 } },
  105. { MODKEY, GDK_KEY_r, reload, { .b = 0 } },
  106. { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
  107. { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
  108. /* Currently we have to use scrolling steps that WebKit2GTK+ gives us
  109. * d: step down, u: step up, r: step right, l:step left
  110. * D: page down, U: page up */
  111. { MODKEY, GDK_KEY_j, scroll, { .i = 'd' } },
  112. { MODKEY, GDK_KEY_k, scroll, { .i = 'u' } },
  113. { MODKEY, GDK_KEY_b, scroll, { .i = 'U' } },
  114. { MODKEY, GDK_KEY_space, scroll, { .i = 'D' } },
  115. { MODKEY, GDK_KEY_i, scroll, { .i = 'r' } },
  116. { MODKEY, GDK_KEY_u, scroll, { .i = 'l' } },
  117. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
  118. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
  119. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
  120. { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
  121. { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
  122. { MODKEY, GDK_KEY_p, clipboard, { .b = 1 } },
  123. { MODKEY, GDK_KEY_y, clipboard, { .b = 0 } },
  124. { MODKEY, GDK_KEY_n, find, { .i = +1 } },
  125. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
  126. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
  127. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
  128. { 0, GDK_KEY_F11, togglefullscreen, { 0 } },
  129. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } },
  130. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } },
  131. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } },
  132. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } },
  133. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } },
  134. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } },
  135. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } },
  136. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
  137. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
  138. { MODKEY, GDK_w, spawn, WATCH },
  139. };
  140. /* button definitions */
  141. /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
  142. static Button buttons[] = {
  143. /* target event mask button function argument stop event */
  144. { OnLink, 0, 2, clicknewwindow, { .b = 0 }, 1 },
  145. { OnLink, MODKEY, 2, clicknewwindow, { .b = 1 }, 1 },
  146. { OnLink, MODKEY, 1, clicknewwindow, { .b = 1 }, 1 },
  147. { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
  148. { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
  149. { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },
  150. };
  151.