surf-history-20181009-2b71a22.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
surf-history-20181009-2b71a22.diff (3405B)
---
1 diff -up surf-2.0/config.def.h surf-2.0-history/config.def.h
2 --- surf-2.0/config.def.h 2017-11-26 14:29:37.963786915 +0100
3 +++ surf-2.0-history/config.def.h 2017-11-26 19:48:31.300096237 +0100
4 @@ -6,6 +6,7 @@ static char *styledir = "~/.surf/s
5 static char *certdir = "~/.surf/certificates/";
6 static char *cachedir = "~/.surf/cache/";
7 static char *cookiefile = "~/.surf/cookies.txt";
8 +static char *historyfile = "~/.surf/history.txt";
9
10 /* Webkit default features */
11 /* Highest priority value will be used.
12 @@ -101,6 +102,11 @@ static WebKitFindOptions findopts = WEBK
13 } \
14 }
15
16 +#define SETURI(p) { .v = (char *[]){ "/bin/sh", "-c", \
17 +"prop=\"`surf_history_dmenu.sh`\" &&" \
18 +"xprop -id $1 -f $0 8s -set $0 \"$prop\"", \
19 +p, winid, NULL } }
20 +
21 /* styles */
22 /*
23 * The iteration will stop at the first match, beginning at the beginning of
24 @@ -181,6 +187,7 @@ static Key keys[] = {
25 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
26 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } },
27 { MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
28 + { MODKEY , GDK_KEY_Return, spawn, SETURI("_SURF_GO") },
29 };
30
31 /* button definitions */
32 Only in surf-2.0-history/: config.h
33 Only in surf-2.0: .git
34 Only in surf-2.0-history/: surf
35 diff -up surf-2.0/surf.c surf-2.0-history/surf.c
36 --- surf-2.0/surf.c 2017-11-26 14:29:37.963786915 +0100
37 +++ surf-2.0-history/surf.c 2017-11-26 14:20:36.757100476 +0100
38 @@ -171,6 +171,7 @@ static void newwindow(Client *c, const A
39 static void spawn(Client *c, const Arg *a);
40 static void destroyclient(Client *c);
41 static void cleanup(void);
42 +static void updatehistory(const char *u, const char *t);
43
44 /* GTK/WebKit */
45 static WebKitWebView *newview(Client *c, WebKitWebView *rv);
46 @@ -336,10 +337,11 @@ setup(void)
47 curconfig = defconfig;
48
49 /* dirs and files */
50 - cookiefile = buildfile(cookiefile);
51 - scriptfile = buildfile(scriptfile);
52 - cachedir = buildpath(cachedir);
53 - certdir = buildpath(certdir);
54 + cookiefile = buildfile(cookiefile);
55 + historyfile = buildfile(historyfile);
56 + scriptfile = buildfile(scriptfile);
57 + cachedir = buildpath(cachedir);
58 + certdir = buildpath(certdir);
59
60 gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy));
61
62 @@ -1042,12 +1044,28 @@ cleanup(void)
63 while (clients)
64 destroyclient(clients);
65 g_free(cookiefile);
66 + g_free(historyfile);
67 g_free(scriptfile);
68 g_free(stylefile);
69 g_free(cachedir);
70 XCloseDisplay(dpy);
71 }
72
73 +void
74 +updatehistory(const char *u, const char *t)
75 +{
76 + FILE *f;
77 + f = fopen(historyfile, "a+");
78 +
79 + char b[20];
80 + time_t now = time (0);
81 + strftime (b, 20, "%Y-%m-%d %H:%M:%S", localtime (&now));
82 + fputs(b, f);
83 +
84 + fprintf(f, " %s %s\n", u, t);
85 + fclose(f);
86 +}
87 +
88 WebKitWebView *
89 newview(Client *c, WebKitWebView *rv)
90 {
91 @@ -1417,6 +1435,7 @@ loadfailedtls(WebKitWebView *v, gchar *u
92 return TRUE;
93 }
94
95 +
96 void
97 loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c)
98 {
99 @@ -1445,6 +1464,7 @@ loadchanged(WebKitWebView *v, WebKitLoad
100 break;
101 case WEBKIT_LOAD_FINISHED:
102 seturiparameters(c, uri, loadfinished);
103 + updatehistory(uri, c->title);
104 /* Disabled until we write some WebKitWebExtension for
105 * manipulating the DOM directly.
106 evalscript(c, "document.documentElement.style.overflow = '%s'",
107 Only in surf-2.0-history/: surf.o