sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 31ec055c1b30bce8eea79a15397ac7c9112cd708
parent de1b1a0561e174be7266b7bd3beb2cb1e12600f9
Author: Marcin sZpak <szpak@reakcja.org>
Date:   Sun, 26 Nov 2017 21:13:21 +0100

history patch working with surf 2.0. Now history is updated on load_finished event. Added date/time.

Diffstat:
Msurf.suckless.org/patches/history.md | 8+++++---
Asurf.suckless.org/patches/surf-history-2.0.diff | 107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 112 insertions(+), 3 deletions(-)

diff --git a/surf.suckless.org/patches/history.md b/surf.suckless.org/patches/history.md @@ -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. @@ -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. @@ -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 ------- @@ -56,3 +57,4 @@ Authors * Jason Thigpen (cdarwin) <[darwin@senet.us](mailto:darwin@senet.us)> * Peter John Hartman (wart_) <[http://durandus.trilidun.org/durandus/](http://durandus.trilidun.org/durandus/)> * Samuel Baldwin (shardz) <[recursive.forest@gmail.com](mailto:recursive.forest@gmail.com)> +* Marcin sZpak <[szpak@reakcja.org](mailto:szpak@reakcja.org)> diff --git a/surf.suckless.org/patches/surf-history-2.0.diff b/surf.suckless.org/patches/surf-history-2.0.diff @@ -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 +@@ -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. +@@ -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 +@@ -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 +@@ -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); +@@ -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)); + +@@ -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\n", u, t); ++ fclose(f); ++} ++ + WebKitWebView * + newview(Client *c, WebKitWebView *rv) + { +@@ -1417,6 +1435,7 @@ loadfailedtls(WebKitWebView *v, gchar *u + return TRUE; + } + ++ + void + loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c) + { +@@ -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