Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

251 lines
10 KiB

4 years ago
  1. /* modifier 0 means no modifier */
  2. static int surfuseragent = 0; /* Append Surf version to default WebKit user agent */
  3. static char *fulluseragent = "Mozilla/5.0 (X11; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0"; /* Or override the whole user agent string */
  4. static char *scriptfiles[] = {
  5. "~/.config/surf/scripts/default.js",
  6. };
  7. static char *styledir = "~/.config/surf/styles/";
  8. static char *certdir = "~/.cache/surf/certificates/";
  9. static char *cachedir = "~/.cache/surf/cache/";
  10. static char *historyfile = "~/.cache/surf/history.txt";
  11. static char *cookiefile = "~/.cache/surf/cookies.txt";
  12. static char *searchengine = "https://google.com/search?q=";
  13. static char **plugindirs = (char*[]){
  14. "~/.config/surf/plugins/",
  15. LIBPREFIX "/mozilla/plugins/",
  16. NULL
  17. };
  18. /* Webkit default features */
  19. /* Highest priority value will be used.
  20. * Default parameters are priority 0
  21. * Per-uri parameters are priority 1
  22. * Command parameters are priority 2
  23. */
  24. static Parameter defconfig[ParameterLast] = {
  25. /* parameter Arg value priority */
  26. [AcceleratedCanvas] = { { .i = 1 }, },
  27. [AccessMicrophone] = { { .i = 0 }, },
  28. [AccessWebcam] = { { .i = 0 }, },
  29. [Certificate] = { { .i = 0 }, },
  30. [CaretBrowsing] = { { .i = 0 }, },
  31. [CookiePolicies] = { { .v = "A" }, },
  32. [DefaultCharset] = { { .v = "UTF-8" }, },
  33. [DiskCache] = { { .i = 1 }, },
  34. [DNSPrefetch] = { { .i = 0 }, },
  35. [Ephemeral] = { { .i = 0 }, },
  36. [FileURLsCrossAccess] = { { .i = 0 }, },
  37. [FontSize] = { { .i = 12 }, },
  38. [FrameFlattening] = { { .i = 0 }, },
  39. [Geolocation] = { { .i = 0 }, },
  40. [HideBackground] = { { .i = 0 }, },
  41. [Inspector] = { { .i = 0 }, },
  42. [Java] = { { .i = 1 }, },
  43. [JavaScript] = { { .i = 1 }, },
  44. [KioskMode] = { { .i = 0 }, },
  45. [LoadImages] = { { .i = 1 }, },
  46. [MediaManualPlay] = { { .i = 1 }, },
  47. [Plugins] = { { .i = 1 }, },
  48. [PreferredLanguages] = { { .v = (char *[]){ NULL } }, },
  49. [RunInFullscreen] = { { .i = 0 }, },
  50. [ScrollBars] = { { .i = 1 }, },
  51. [ShowIndicators] = { { .i = 1 }, },
  52. [SiteQuirks] = { { .i = 1 }, },
  53. [SmoothScrolling] = { { .i = 0 }, },
  54. [SpellChecking] = { { .i = 0 }, },
  55. [SpellLanguages] = { { .v = ((char *[]){ "en_US", NULL }) }, },
  56. [StrictTLS] = { { .i = 1 }, },
  57. [Style] = { { .i = 1 }, },
  58. [WebGL] = { { .i = 0 }, },
  59. [ZoomLevel] = { { .f = 1.0 }, },
  60. [ClipboardNotPrimary] = { { .i = 1 }, },
  61. };
  62. #define SETURI(p) { .v = (char *[]){ "/bin/sh", "-c", \
  63. "prop=\"`surf_history_dmenu.sh`\" &&" \
  64. "xprop -id $1 -f $0 8s -set $0 \"$prop\"", \
  65. p, winid, NULL } }
  66. static UriParameters uriparams[] = {
  67. { "(://|\\.)suckless\\.org(/|$)", {
  68. [JavaScript] = { { .i = 0 }, 1 },
  69. [Plugins] = { { .i = 0 }, 1 },
  70. }, },
  71. };
  72. /* default window size: width, height */
  73. static int winsize[] = { 800, 600 };
  74. static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
  75. WEBKIT_FIND_OPTIONS_WRAP_AROUND;
  76. #define PROMPT_GO "Go:"
  77. #define PROMPT_FIND "Find:"
  78. /* SETPROP(readprop, setprop, prompt)*/
  79. #define SETPROP(r, s, p) { \
  80. .v = (const char *[]){ "/bin/sh", "-c", \
  81. "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
  82. "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\" && cat ~/.config/surf/bookmarks)\" " \
  83. "| dmenu -l 10 -p \"$4\" -w $1)\" && " \
  84. "xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
  85. "surf-setprop", winid, r, s, p, NULL \
  86. } \
  87. }
  88. /* DOWNLOAD(URI, referer) */
  89. #define DOWNLOAD(d, r) { \
  90. .v = (char *[]){ "/bin/sh", "-c", \
  91. "cd ~/Downloads;"\
  92. "st -e /bin/sh -c \"aria2c -U '$1'" \
  93. " --referer '$2' --load-cookies $3 --save-cookies $3 '$0';" \
  94. " sleep 3;\"", \
  95. d, useragent, r, cookiefile, NULL \
  96. } \
  97. }
  98. /* PLUMB(URI) */
  99. /* This called when some URI which does not begin with "about:",
  100. * "http://" or "https://" should be opened.
  101. */
  102. #define PLUMB(u) {\
  103. .v = (const char *[]){ "/bin/sh", "-c", \
  104. "xdg-open \"$0\"", u, NULL \
  105. } \
  106. }
  107. /* VIDEOPLAY(URI) */
  108. #define VIDEOPLAY(u) {\
  109. .v = (const char *[]){ "/bin/sh", "-c", \
  110. "mpv --really-quiet \"$0\"", u, NULL \
  111. } \
  112. }
  113. /* BM_ADD(readprop) */
  114. #define BM_ADD(r) {\
  115. .v = (const char *[]){ "/bin/sh", "-c", \
  116. "(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \
  117. "| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.config/surf/bookmarks) " \
  118. "| awk '!seen[$0]++' > ~/.config/surf/bookmarks.tmp && " \
  119. "mv ~/.config/surf/bookmarks.tmp ~/.config/surf/bookmarks", \
  120. winid, r, NULL \
  121. } \
  122. }
  123. /* styles */
  124. /*
  125. * The iteration will stop at the first match, beginning at the beginning of
  126. * the list.
  127. */
  128. static SiteSpecific styles[] = {
  129. /* regexp file in $styledir */
  130. { ".*", "localwiki.css" },
  131. };
  132. /* certificates */
  133. /*
  134. * Provide custom certificate for urls
  135. */
  136. static SiteSpecific certs[] = {
  137. /* regexp file in $certdir */
  138. { "://suckless\\.org/", "suckless.org.crt" },
  139. };
  140. #define MODKEY GDK_CONTROL_MASK
  141. static char *linkselect_curwin [] = { "/bin/sh", "-c",
  142. "surf_linkselect.sh $0 'Link' | xargs -r xprop -id $0 -f _SURF_GO 8s -set _SURF_GO",
  143. winid, NULL
  144. };
  145. static char *linkselect_newwin [] = { "/bin/sh", "-c",
  146. "surf_linkselect.sh $0 'Link (new window)' | xargs -r /home/yigit/.scripts/tabbed_surf",
  147. winid, NULL
  148. };
  149. static char *editscreen[] = { "/bin/sh", "-c", "edit_screen.sh", NULL };
  150. #define WATCH {.v = (char *[]){ "/bin/sh", "-c", \
  151. "/home/yigit/.scripts/watch_mpv.sh $(xprop -id $0 _SURF_URI | cut -d \\\" -f 2)", \
  152. winid, NULL } }
  153. #define WALLABAG {.v = (char *[]){ "/bin/sh", "-c", \
  154. "wallabag add $(xprop -id $0 _SURF_URI | cut -d '\"' -f 2) ; echo test > /tmp/aaa", \
  155. winid, NULL }}
  156. /* hotkeys */
  157. /*
  158. * If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
  159. * edit the CLEANMASK() macro.
  160. */
  161. static Key keys[] = {
  162. /* modifier keyval function arg */
  163. { 0, GDK_KEY_i, insert, { .i = 1 } },
  164. { 0, GDK_KEY_Escape, insert, { .i = 0 } },
  165. { 0, GDK_KEY_o, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
  166. { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
  167. { MODKEY, GDK_KEY_b, spawn, BM_ADD("_SURF_URI") },
  168. { 0, GDK_KEY_Escape, stop, { 0 } },
  169. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
  170. { MODKEY, GDK_KEY_r, reload, { .i = 0 } },
  171. { 0, GDK_KEY_l, navigate, { .i = +1 } },
  172. { 0, GDK_KEY_h, navigate, { .i = -1 } },
  173. /* vertical and horizontal scrolling, in viewport percentage */
  174. { 0, GDK_KEY_j, scrollv, { .i = +10 } },
  175. { 0, GDK_KEY_k, scrollv, { .i = -10 } },
  176. { 0, GDK_KEY_space, scrollv, { .i = +50 } },
  177. { 0, GDK_KEY_b, scrollv, { .i = -50 } },
  178. { 0, GDK_KEY_u, scrollh, { .i = -10 } },
  179. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
  180. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
  181. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
  182. { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
  183. { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
  184. { 0, GDK_KEY_p, clipboard, { .i = 1 } },
  185. { 0, GDK_KEY_y, clipboard, { .i = 0 } },
  186. { 0, GDK_KEY_n, find, { .i = +1 } },
  187. { GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
  188. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
  189. { MODKEY, GDK_KEY_t, showcert, { 0 } },
  190. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
  191. { 0, GDK_KEY_F11, togglefullscreen, { 0 } },
  192. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } },
  193. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } },
  194. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } },
  195. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } },
  196. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } },
  197. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_v, toggle, { .i = Plugins } },
  198. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
  199. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } },
  200. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
  201. { MODKEY, GDK_KEY_d, externalpipe, { .v = linkselect_curwin } },
  202. { GDK_SHIFT_MASK|MODKEY, GDK_KEY_d, externalpipe, { .v = linkselect_newwin } },
  203. { MODKEY, GDK_KEY_o, externalpipe, { .v = editscreen } },
  204. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_w, spawn, WATCH },
  205. { MODKEY, GDK_KEY_m, spawn, WALLABAG },
  206. { MODKEY , GDK_KEY_Return, spawn, SETURI("_SURF_GO") },
  207. };
  208. /* button definitions */
  209. /* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
  210. static Button buttons[] = {
  211. /* target event mask button function argument stop event */
  212. { OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 },
  213. { OnLink, MODKEY, 2, clicknewwindow, { .i = 0 }, 1 },
  214. { OnLink, MODKEY, 1, clicknewwindow, { .i = 0 }, 1 },
  215. { OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
  216. { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
  217. { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },
  218. };
  219. #define HOMEPAGE "http://localhost:9999"