surf

A surf web browser [kocotian build]
git clone git://git.kocotian.pl/surf.git
Log | Files | Refs | README | LICENSE

commit d00d596fcc5de485050ae2661751b12b7adeaa33
parent dc965f4d65d262401b0e1630d0e37f77a7961b72
Author: kocotian <kocotian@kocotian.pl>
Date:   Wed, 16 Dec 2020 18:37:43 +0100

applied a few patches, make clean updated

Diffstat:
MMakefile | 1+
Mconfig.def.h | 18+++++++++++++++---
Mpatches/surf-2.0-homepage.diff | 0
Mpatches/surf-history-20181009-2b71a22.diff | 0
Mpatches/surf-startgo-20200913-d068a38.diff | 0
Msurf.1 | 5++++-
Msurf.c | 33+++++++++++++++++++++++++++++++++
7 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile @@ -39,6 +39,7 @@ $(WOBJ): $(WSRC) clean: rm -f surf $(OBJ) rm -f $(WLIB) $(WOBJ) + rm -f *.rej *.orig distclean: clean rm -f config.h surf-$(VERSION).tar.gz diff --git a/config.def.h b/config.def.h @@ -4,14 +4,18 @@ static char *fulluseragent = ""; /* Or override the whole user agent string */ static char *scriptfile = "~/.config/surf/script.js"; static char *styledir = "~/.config/surf/styles/"; static char *certdir = "~/.config/surf/certificates/"; -static char *cachedir = "~/.config/surf/cache/"; -static char *cookiefile = "~/.config/surf/cookies.txt"; +static char *cachedir = "~/.cache/surf/cache"; +static char *cookiefile = "~/.cache/surf/cookies.txt"; +static char *historyfile = "~/.cache/surf/history"; static char **plugindirs = (char*[]){ - "~/.surf/plugins/", + "~/.config/surf/plugins/", LIBPREFIX "/mozilla/plugins/", NULL }; +/* enable to open GO prompt on startup */ +static int startgo = 0; + /* Webkit default features */ /* Highest priority value will be used. * Default parameters are priority 0 @@ -108,6 +112,11 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | } \ } +#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 @@ -186,6 +195,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 */ @@ -199,3 +209,5 @@ static Button buttons[] = { { OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 }, { OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 }, }; + +#define HOMEPAGE "https://duckduckgo.com/" diff --git a/patches/surf-2.0-homepage.diff b/patches/surf-2.0-homepage.diff diff --git a/patches/surf-history-20181009-2b71a22.diff b/patches/surf-history-20181009-2b71a22.diff diff --git a/patches/surf-startgo-20200913-d068a38.diff b/patches/surf-startgo-20200913-d068a38.diff diff --git a/surf.1 b/surf.1 @@ -3,7 +3,7 @@ surf \- simple webkit-based browser .SH SYNOPSIS .B surf -.RB [-bBdDfFgGiIkKmMnNpPsStTvwxX] +.RB [-bBdDfFgGhiIkKmMnNpPsStTvwxX] .RB [-a\ cookiepolicies] .RB [-c\ cookiefile] .RB [-C\ stylefile] @@ -67,6 +67,9 @@ Disable giving the geolocation to websites. .B \-G Enable giving the geolocation to websites. .TP +.B \-h +Start the GO prompt immediately. +.TP .B \-i Disable Images. .TP diff --git a/surf.c b/surf.c @@ -179,6 +179,7 @@ static void spawn(Client *c, const Arg *a); static void msgext(Client *c, char type, 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); @@ -352,6 +353,7 @@ setup(void) /* dirs and files */ cookiefile = buildfile(cookiefile); + historyfile = buildfile(historyfile); scriptfile = buildfile(scriptfile); certdir = buildpath(certdir); if (curconfig[Ephemeral].val.i) @@ -1097,12 +1099,28 @@ cleanup(void) close(spair[0]); close(spair[1]); 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) { @@ -1518,6 +1536,7 @@ loadfailedtls(WebKitWebView *v, gchar *uri, GTlsCertificate *cert, return TRUE; } + void loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c) { @@ -1548,6 +1567,7 @@ loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c) 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'", @@ -2058,6 +2078,9 @@ main(int argc, char *argv[]) defconfig[Geolocation].val.i = 1; defconfig[Geolocation].prio = 2; break; + case 'h': + startgo = 1; + break; case 'i': defconfig[LoadImages].val.i = 0; defconfig[LoadImages].prio = 2; @@ -2143,7 +2166,11 @@ main(int argc, char *argv[]) if (argc > 0) arg.v = argv[0]; else +#ifdef HOMEPAGE + arg.v = HOMEPAGE; +#else arg.v = "about:blank"; +#endif setup(); c = newclient(NULL); @@ -2152,6 +2179,12 @@ main(int argc, char *argv[]) loaduri(c, &arg); updatetitle(c); + if (startgo) { + /* start directly into GO prompt */ + Arg a = (Arg)SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO); + spawn(c, &a); + } + gtk_main(); cleanup();