config.def.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. static char *searchurl = "duckduckgo.com/?q=%s";
  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. #define SEARCH() { \
  55. .v = (const char *[]){ "/bin/sh", "-c", \
  56. "xprop -id $1 -f $2 8s -set $2 \"" \
  57. "$(dmenu -p Search: -w $1 < /dev/null)\"", \
  58. "surf-search", winid, "_SURF_SEARCH", NULL \
  59. } \
  60. }
  61. /* DOWNLOAD(URI, referer) */
  62. #define DOWNLOAD(d, r) { \
  63. .v = (const char *[]){ "/bin/sh", "-c", \
  64. "st -e /bin/sh -c \"curl -g -L -J -O --user-agent '$1'" \
  65. " --referer '$2' -b $3 -c $3 '$0';" \
  66. " sleep 5;\"", \
  67. d, useragent, r, cookiefile, NULL \
  68. } \
  69. }
  70. /* PLUMB(URI) */
  71. /* This called when some URI which does not begin with "about:",
  72. * "http://" or "https://" should be opened.
  73. */
  74. #define PLUMB(u) {\
  75. .v = (const char *[]){ "/bin/sh", "-c", \
  76. "xdg-open \"$0\"", u, NULL \
  77. } \
  78. }
  79. /* VIDEOPLAY(URI) */
  80. #define VIDEOPLAY(u) {\
  81. .v = (const char *[]){ "/bin/sh", "-c", \
  82. "mpv --really-quiet \"$0\"", u, NULL \
  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. #define MODKEY GDK_CONTROL_MASK
  95. /* hotkeys */
  96. /*
  97. * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
  98. * edit the CLEANMASK() macro.
  99. */
  100. static Key keys[] = {
  101. /* modifier keyval function arg */
  102. { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") },
  103. { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
  104. { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
  105. { 0, GDK_KEY_Escape, stop, { 0 } },
  106. { MODKEY, GDK_KEY_c, stop, { 0 } },
  107. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .b = 1 } },
  108. { MODKEY, GDK_KEY_r, reload, { .b = 0 } },
  109. { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
  110. { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
  111. /* Currently we have to use scrolling steps that WebKit2GTK+ gives us
  112. * d: step down, u: step up, r: step right, l:step left
  113. * D: page down, U: page up */
  114. { MODKEY, GDK_KEY_j, scroll, { .i = 'd' } },
  115. { MODKEY, GDK_KEY_k, scroll, { .i = 'u' } },
  116. { MODKEY, GDK_KEY_b, scroll, { .i = 'U' } },
  117. { MODKEY, GDK_KEY_space, scroll, { .i = 'D' } },
  118. { MODKEY, GDK_KEY_i, scroll, { .i = 'r' } },
  119. { MODKEY, GDK_KEY_u, scroll, { .i = 'l' } },
  120. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
  121. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
  122. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
  123. { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
  124. { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
  125. { MODKEY, GDK_KEY_s, spawn, SEARCH() },
  126. { MODKEY, GDK_KEY_p, clipboard, { .b = 1 } },
  127. { MODKEY, GDK_KEY_y, clipboard, { .b = 0 } },
  128. { MODKEY, GDK_KEY_n, find, { .i = +1 } },
  129. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
  130. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
  131. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
  132. { 0, GDK_KEY_F11, togglefullscreen, { 0 } },
  133. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } },
  134. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } },
  135. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } },
  136. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } },
  137. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } },
  138. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } },
  139. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } },
  140. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
  141. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
  142. };
  143. /* button definitions */
  144. /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
  145. static Button buttons[] = {
  146. /* target event mask button function argument stop event */
  147. { OnLink, 0, 2, clicknewwindow, { .b = 0 }, 1 },
  148. { OnLink, MODKEY, 2, clicknewwindow, { .b = 1 }, 1 },
  149. { OnLink, MODKEY, 1, clicknewwindow, { .b = 1 }, 1 },
  150. { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
  151. { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
  152. { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },
  153. };