config.def.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 *certdir = "~/.surf/certificates/";
  7. static char *cachedir = "~/.surf/cache/";
  8. static char *cookiefile = "~/.surf/cookies.txt";
  9. static char *searchurl = "duckduckgo.com/?q=%s";
  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. static Parameter defconfig[ParameterLast] = {
  17. /* parameter Arg value priority */
  18. [AcceleratedCanvas] = { { .i = 1 }, },
  19. [AccessMicrophone] = { { .i = 0 }, },
  20. [AccessWebcam] = { { .i = 0 }, },
  21. [Certificate] = { { .i = 0 }, },
  22. [CaretBrowsing] = { { .i = 0 }, },
  23. [CookiePolicies] = { { .v = "@Aa" }, },
  24. [DefaultCharset] = { { .v = "UTF-8" }, },
  25. [DiskCache] = { { .i = 1 }, },
  26. [DNSPrefetch] = { { .i = 0 }, },
  27. [FileURLsCrossAccess] = { { .i = 0 }, },
  28. [FontSize] = { { .i = 12 }, },
  29. [FrameFlattening] = { { .i = 0 }, },
  30. [Geolocation] = { { .i = 0 }, },
  31. [HideBackground] = { { .i = 0 }, },
  32. [Inspector] = { { .i = 0 }, },
  33. [Java] = { { .i = 1 }, },
  34. [JavaScript] = { { .i = 1 }, },
  35. [KioskMode] = { { .i = 0 }, },
  36. [LoadImages] = { { .i = 1 }, },
  37. [MediaManualPlay] = { { .i = 1 }, },
  38. [Plugins] = { { .i = 1 }, },
  39. [PreferredLanguages] = { { .v = (char *[]){ NULL } }, },
  40. [RunInFullscreen] = { { .i = 0 }, },
  41. [ScrollBars] = { { .i = 1 }, },
  42. [ShowIndicators] = { { .i = 1 }, },
  43. [SiteQuirks] = { { .i = 1 }, },
  44. [SmoothScrolling] = { { .i = 0 }, },
  45. [SpellChecking] = { { .i = 0 }, },
  46. [SpellLanguages] = { { .v = ((char *[]){ "en_US", NULL }) }, },
  47. [StrictTLS] = { { .i = 1 }, },
  48. [Style] = { { .i = 1 }, },
  49. [WebGL] = { { .i = 0 }, },
  50. [ZoomLevel] = { { .f = 1.0 }, },
  51. [ClipboardNotPrimary] = { { .i = 1 }, },
  52. };
  53. static UriParameters uriparams[] = {
  54. { "(://|\\.)suckless\\.org(/|$)", {
  55. [JavaScript] = { { .i = 0 }, 1 },
  56. [Plugins] = { { .i = 0 }, 1 },
  57. }, },
  58. };
  59. /* default window size: width, height */
  60. static int winsize[] = { 800, 600 };
  61. static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
  62. WEBKIT_FIND_OPTIONS_WRAP_AROUND;
  63. #define PROMPT_GO "Go:"
  64. #define PROMPT_FIND "Find:"
  65. /* SETPROP(readprop, setprop, prompt)*/
  66. #define SETPROP(r, s, p) { \
  67. .v = (const char *[]){ "/bin/sh", "-c", \
  68. "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
  69. "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \
  70. "| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
  71. "surf-setprop", winid, r, s, p, NULL \
  72. } \
  73. }
  74. #define SEARCH() { \
  75. .v = (const char *[]){ "/bin/sh", "-c", \
  76. "xprop -id $1 -f $2 8s -set $2 \"" \
  77. "$(dmenu -p Search: -w $1 < /dev/null)\"", \
  78. "surf-search", winid, "_SURF_SEARCH", NULL \
  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. /* PLUMB(URI) */
  90. /* This called when some URI which does not begin with "about:",
  91. * "http://" or "https://" should be opened.
  92. */
  93. #define PLUMB(u) {\
  94. .v = (const char *[]){ "/bin/sh", "-c", \
  95. "xdg-open \"$0\"", u, NULL \
  96. } \
  97. }
  98. /* VIDEOPLAY(URI) */
  99. #define VIDEOPLAY(u) {\
  100. .v = (const char *[]){ "/bin/sh", "-c", \
  101. "mpv --really-quiet \"$0\"", u, NULL \
  102. } \
  103. }
  104. /* styles */
  105. /*
  106. * The iteration will stop at the first match, beginning at the beginning of
  107. * the list.
  108. */
  109. static SiteSpecific styles[] = {
  110. /* regexp file in $styledir */
  111. { ".*", "default.css" },
  112. };
  113. /* certificates */
  114. /*
  115. * Provide custom certificate for urls
  116. */
  117. static SiteSpecific certs[] = {
  118. /* regexp file in $certdir */
  119. { "://suckless\\.org/", "suckless.org.crt" },
  120. };
  121. #define MODKEY GDK_CONTROL_MASK
  122. /* hotkeys */
  123. /*
  124. * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
  125. * edit the CLEANMASK() macro.
  126. */
  127. static Key keys[] = {
  128. /* modifier keyval function arg */
  129. { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
  130. { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
  131. { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
  132. { MODKEY, GDK_KEY_s, spawn, SEARCH() },
  133. { 0, GDK_KEY_Escape, stop, { 0 } },
  134. { MODKEY, GDK_KEY_c, stop, { 0 } },
  135. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
  136. { MODKEY, GDK_KEY_r, reload, { .i = 0 } },
  137. { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
  138. { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
  139. /* vertical and horizontal scrolling, in viewport percentage */
  140. { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } },
  141. { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } },
  142. { MODKEY, GDK_KEY_space, scrollv, { .i = +50 } },
  143. { MODKEY, GDK_KEY_b, scrollv, { .i = -50 } },
  144. { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } },
  145. { MODKEY, GDK_KEY_u, scrollh, { .i = -10 } },
  146. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
  147. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
  148. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
  149. { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
  150. { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
  151. { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } },
  152. { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } },
  153. { MODKEY, GDK_KEY_n, find, { .i = +1 } },
  154. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
  155. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
  156. { MODKEY, GDK_KEY_t, showcert, { 0 } },
  157. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
  158. { 0, GDK_KEY_F11, togglefullscreen, { 0 } },
  159. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } },
  160. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } },
  161. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } },
  162. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } },
  163. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } },
  164. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } },
  165. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } },
  166. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
  167. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } },
  168. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
  169. };
  170. /* button definitions */
  171. /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
  172. static Button buttons[] = {
  173. /* target event mask button function argument stop event */
  174. { OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 },
  175. { OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 },
  176. { OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 },
  177. { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
  178. { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
  179. { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },
  180. };