config.def.h 8.0 KB

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