commit 31ec055c1b30bce8eea79a15397ac7c9112cd708
Author: Marcin sZpak <szpak_AT_reakcja.org>
Date: Sun Nov 26 21:13:21 2017 +0100
history patch working with surf 2.0. Now history is updated on load_finished event. Added date/time.
diff --git a/surf.suckless.org/patches/history.md b/surf.suckless.org/patches/history.md
index 0890b3ee..3176bfe1 100644
--- a/surf.suckless.org/patches/history.md
+++ b/surf.suckless.org/patches/history.md
_AT_@ -11,9 +11,9 @@ add the following:
Here are some ways of using it.
-(1) Write a small shell script.
+(1) Write a small shell script (dmenu.uri.sh)
- cat ~/.surf/history | sort -ru | dmenu -l 10 -b -i | xprop -id `cat ~/.surf/id` -f SURF_URI 8s -set _SURF_URI
+ tac ~/.surf/history | dmenu -l 10 -b -i | cut -d ' ' -f 3
(2) Modify config.h and add the following.
_AT_@ -24,7 +24,7 @@ Here are some ways of using it.
and in static Key keys[] add:
- { MODKEY, GDK_Return, spawn, SETURI("_SURF_URI") },
+ { MODKEY, GDK_Return, spawn, SETURI("_SURF_GO") },
Here are some tips on using it.
_AT_@ -49,6 +49,7 @@ Download
* [surf-0.3-history.diff](surf-0.3-history.diff) (1475) (20091203)
* [surf-tip-history.diff](surf-tip-history.diff) (2952) (20091215)
* [surf-0.4.1-history.diff](surf-0.4.1-history.diff) (1346) (20101225)
+* [surf-history-2.0.diff](surf-history-2.0.diff) (3405) (20171126)
Authors
-------
_AT_@ -56,3 +57,4 @@ Authors
* Jason Thigpen (cdarwin) <[darwin_AT_senet.us](mailto:darwin_AT_senet.us)>
* Peter John Hartman (wart_) <[
http://durandus.trilidun.org/durandus/](
http://durandus.trilidun.org/durandus/)>
* Samuel Baldwin (shardz) <[recursive.forest_AT_gmail.com](mailto:recursive.forest_AT_gmail.com)>
+* Marcin sZpak <[szpak_AT_reakcja.org](mailto:szpak_AT_reakcja.org)>
diff --git a/surf.suckless.org/patches/surf-history-2.0.diff b/surf.suckless.org/patches/surf-history-2.0.diff
new file mode 100644
index 00000000..40192c55
--- /dev/null
+++ b/surf.suckless.org/patches/surf-history-2.0.diff
_AT_@ -0,0 +1,107 @@
+diff -up surf-2.0/config.def.h surf-2.0-history/config.def.h
+--- surf-2.0/config.def.h 2017-11-26 14:29:37.963786915 +0100
++++ surf-2.0-history/config.def.h 2017-11-26 19:48:31.300096237 +0100
+_AT_@ -6,6 +6,7 @@ static char *styledir = "~/.surf/s
+ static char *certdir = "~/.surf/certificates/";
+ static char *cachedir = "~/.surf/cache/";
+ static char *cookiefile = "~/.surf/cookies.txt";
++static char *historyfile = "~/.surf/history.txt";
+
+ /* Webkit default features */
+ /* Highest priority value will be used.
+_AT_@ -101,6 +102,11 @@ static WebKitFindOptions findopts = WEBK
+ } \
+ }
+
++#define SETURI(p) { .v = (char *[]){ "/bin/sh", "-c", \
++"prop=\"`surf_history_dmenu.sh`\" &&" \
++"xprop -id $1 -f $0 8s -set $0 \"$prop\"", \
++p, winid, NULL } }
++
+ /* styles */
+ /*
+ * The iteration will stop at the first match, beginning at the beginning of
+_AT_@ -181,6 +187,7 @@ static Key keys[] = {
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
++ { MODKEY , GDK_KEY_Return, spawn, SETURI("_SURF_GO") },
+ };
+
+ /* button definitions */
+Only in surf-2.0-history/: config.h
+Only in surf-2.0: .git
+Only in surf-2.0-history/: surf
+diff -up surf-2.0/surf.c surf-2.0-history/surf.c
+--- surf-2.0/surf.c 2017-11-26 14:29:37.963786915 +0100
++++ surf-2.0-history/surf.c 2017-11-26 14:20:36.757100476 +0100
+_AT_@ -171,6 +171,7 @@ static void newwindow(Client *c, const A
+ static void spawn(Client *c, const Arg *a);
+ static void destroyclient(Client *c);
+ static void cleanup(void);
++static void updatehistory(const char *u, const char *t);
+
+ /* GTK/WebKit */
+ static WebKitWebView *newview(Client *c, WebKitWebView *rv);
+_AT_@ -336,10 +337,11 @@ setup(void)
+ curconfig = defconfig;
+
+ /* dirs and files */
+- cookiefile = buildfile(cookiefile);
+- scriptfile = buildfile(scriptfile);
+- cachedir = buildpath(cachedir);
+- certdir = buildpath(certdir);
++ cookiefile = buildfile(cookiefile);
++ historyfile = buildfile(historyfile);
++ scriptfile = buildfile(scriptfile);
++ cachedir = buildpath(cachedir);
++ certdir = buildpath(certdir);
+
+ gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy));
+
+_AT_@ -1042,12 +1044,28 @@ cleanup(void)
+ while (clients)
+ destroyclient(clients);
+ g_free(cookiefile);
++ g_free(historyfile);
+ g_free(scriptfile);
+ g_free(stylefile);
+ g_free(cachedir);
+ XCloseDisplay(dpy);
+ }
+
++void
++updatehistory(const char *u, const char *t)
++{
++ FILE *f;
++ f = fopen(historyfile, "a+");
++
++ char b[20];
++ time_t now = time (0);
++ strftime (b, 20, "%Y-%m-%d %H:%M:%S", localtime (&now));
++ fputs(b, f);
++
++ fprintf(f, " %s %s
", u, t);
++ fclose(f);
++}
++
+ WebKitWebView *
+ newview(Client *c, WebKitWebView *rv)
+ {
+_AT_@ -1417,6 +1435,7 @@ loadfailedtls(WebKitWebView *v, gchar *u
+ return TRUE;
+ }
+
++
+ void
+ loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c)
+ {
+_AT_@ -1445,6 +1464,7 @@ loadchanged(WebKitWebView *v, WebKitLoad
+ break;
+ case WEBKIT_LOAD_FINISHED:
+ seturiparameters(c, uri, loadfinished);
++ updatehistory(uri, c->title);
+ /* Disabled until we write some WebKitWebExtension for
+ * manipulating the DOM directly.
+ evalscript(c, "document.documentElement.style.overflow = '%s'",
+Only in surf-2.0-history/: surf.o
Received on Sun Nov 26 2017 - 21:16:23 CET