config.def.h.orig 6.5 KB

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