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.

101 lines
3.0 KiB

  1. From 8d8ca34a8e61733711e23ce43b88435bfdfd4962 Mon Sep 17 00:00:00 2001
  2. From: knary <theknary@gmail.com>
  3. Date: Mon, 25 Mar 2019 15:03:15 -0400
  4. Subject: [PATCH] This patch replaces scriptfile with an array of
  5. scriptfiles[]. This allows for the inclusion of multiple javascript files
  6. instead of filling up one file with multiple script plugins.
  7. ---
  8. config.def.h | 4 +++-
  9. surf.c | 23 +++++++++++++++--------
  10. 2 files changed, 18 insertions(+), 9 deletions(-)
  11. diff --git a/config.def.h b/config.def.h
  12. index 34265f6..7d7d68e 100644
  13. --- a/config.def.h
  14. +++ b/config.def.h
  15. @@ -1,11 +1,13 @@
  16. /* modifier 0 means no modifier */
  17. static int surfuseragent = 1; /* Append Surf version to default WebKit user agent */
  18. static char *fulluseragent = ""; /* Or override the whole user agent string */
  19. -static char *scriptfile = "~/.surf/script.js";
  20. static char *styledir = "~/.surf/styles/";
  21. static char *certdir = "~/.surf/certificates/";
  22. static char *cachedir = "~/.surf/cache/";
  23. static char *cookiefile = "~/.surf/cookies.txt";
  24. +static char *scriptfiles[] = {
  25. + "~/.surf/script.js",
  26. +};
  27. /* Webkit default features */
  28. /* Highest priority value will be used.
  29. diff --git a/surf.c b/surf.c
  30. index 2b54e3c..34a75de 100644
  31. --- a/surf.c
  32. +++ b/surf.c
  33. @@ -337,9 +337,11 @@ setup(void)
  34. /* dirs and files */
  35. cookiefile = buildfile(cookiefile);
  36. - scriptfile = buildfile(scriptfile);
  37. cachedir = buildpath(cachedir);
  38. certdir = buildpath(certdir);
  39. + for (i = 0; i < LENGTH(scriptfiles); i++) {
  40. + scriptfiles[i] = buildfile(scriptfiles[i]);
  41. + }
  42. gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy));
  43. @@ -945,9 +947,11 @@ runscript(Client *c)
  44. gchar *script;
  45. gsize l;
  46. - if (g_file_get_contents(scriptfile, &script, &l, NULL) && l)
  47. - evalscript(c, "%s", script);
  48. - g_free(script);
  49. + for (int i = 0; i < LENGTH(scriptfiles); i++) {
  50. + if (g_file_get_contents(scriptfiles[i], &script, &l, NULL) && l)
  51. + evalscript(c, "%s", script);
  52. + g_free(script);
  53. + }
  54. }
  55. void
  56. @@ -1010,9 +1014,9 @@ newwindow(Client *c, const Arg *a, int noembed)
  57. cmd[i++] = curconfig[Style].val.i ? "-M" : "-m" ;
  58. cmd[i++] = curconfig[Inspector].val.i ? "-N" : "-n" ;
  59. cmd[i++] = curconfig[Plugins].val.i ? "-P" : "-p" ;
  60. - if (scriptfile && g_strcmp0(scriptfile, "")) {
  61. + if (scriptfiles[0] && g_strcmp0(scriptfiles[0], "")) {
  62. cmd[i++] = "-r";
  63. - cmd[i++] = scriptfile;
  64. + cmd[i++] = scriptfiles[0];
  65. }
  66. cmd[i++] = curconfig[JavaScript].val.i ? "-S" : "-s";
  67. cmd[i++] = curconfig[StrictTLS].val.i ? "-T" : "-t";
  68. @@ -1076,9 +1080,12 @@ cleanup(void)
  69. close(pipein[0]);
  70. close(pipeout[1]);
  71. g_free(cookiefile);
  72. - g_free(scriptfile);
  73. g_free(stylefile);
  74. g_free(cachedir);
  75. + for (int i = 0; i < LENGTH(scriptfiles); i++) {
  76. + g_free(scriptfiles[i]);
  77. + }
  78. +
  79. XCloseDisplay(dpy);
  80. }
  81. @@ -2067,7 +2074,7 @@ main(int argc, char *argv[])
  82. defconfig[Plugins].prio = 2;
  83. break;
  84. case 'r':
  85. - scriptfile = EARGF(usage());
  86. + scriptfiles[0] = EARGF(usage());
  87. break;
  88. case 's':
  89. defconfig[JavaScript].val.i = 0;
  90. --
  91. 2.21.0