diff --git a/config.def.h b/config.def.h index a1ab211..058f2e2 100644 --- a/config.def.h +++ b/config.def.h @@ -16,6 +16,7 @@ static gfloat zoomlevel = 1.0; /* Default zoom level */ /* Soup default features */ static char *cookiefile = "~/.surf/cookies.txt"; +static char *historyfile = "~/.surf/history.txt"; static char *cookiepolicies = "Aa@"; /* A: accept all; a: accept nothing, @: accept no third party */ static char *cafile = "/etc/ssl/certs/ca-certificates.crt"; @@ -63,6 +64,17 @@ static Bool allowgeolocation = TRUE; } \ } +/* HIST */ +#define HISTORY(p, q) { \ + .v = (char *[]){ "/bin/sh", "-c", \ + "prop=\"`(xprop -id $2 $0 "\ + " | cut -d '\"' -f 2 | xargs -0 printf %b && "\ + "cat ~/.surf/history) | dmenu -l 10 -i -p history`\" &&" \ + "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \ + p, q, winid, NULL \ + } \ +} + /* styles */ /* * The iteration will stop at the first match, beginning at the beginning of @@ -113,6 +125,7 @@ static Key keys[] = { { MODKEY, GDK_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") }, { MODKEY, GDK_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, { MODKEY, GDK_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, + { MODKEY|GDK_SHIFT_MASK,GDK_h, spawn, HISTORY("_SURF_URI", "_SURF_GO") }, { MODKEY, GDK_n, find, { .b = TRUE } }, { MODKEY|GDK_SHIFT_MASK,GDK_n, find, { .b = FALSE } }, diff --git a/surf.c b/surf.c index 87c10ef..118627e 100644 --- a/surf.c +++ b/surf.c @@ -319,6 +319,7 @@ cleanup(void) { while(clients) destroyclient(clients); g_free(cookiefile); + g_free(historyfile); g_free(scriptfile); g_free(stylefile); } @@ -772,6 +773,10 @@ loaduri(Client *c, const Arg *arg) { reload(c, &a); } else { webkit_web_view_load_uri(c->view, u); + FILE *f; + f = fopen(historyfile, "a+"); + fprintf(f, "\n%s", u); + fclose(f); c->progress = 0; c->title = copystr(&c->title, u); updatetitle(c); @@ -1222,6 +1227,7 @@ setup(void) { /* dirs and files */ cookiefile = buildpath(cookiefile); + historyfile = buildpath(historyfile); scriptfile = buildpath(scriptfile); cachefolder = buildpath(cachefolder); styledir = buildpath(styledir);