commit c8c9061f37b05253ebdfc2c08d82dc67d2aa0bb2
parent 10f27482688416dcc96383ffb8e705494217da61
Author: Matsuda Kenji <contact2655@matsudakenji.xyz>
Date: Thu, 21 Jul 2022 07:24:20 +0900
add homepage
Diffstat:
10 files changed, 49 insertions(+), 103 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -10,6 +10,7 @@ static char *scriptfiles[] = {
"~/.config/surf/scripts/link_hints.js",
"~/.config/surf/scripts/easier_key.js",
};
+static char *homepage = "file:///home/kenji/.config/surf/home.html";
/* Webkit default features */
/* Highest priority value will be used.
@@ -24,7 +25,7 @@ static Parameter defconfig[ParameterLast] = {
[Certificate] = { { .i = 0 }, },
[CaretBrowsing] = { { .i = 0 }, },
[CookiePolicies] = { { .v = "@Aa" }, },
- [DarkMode] = { { .i = 0 }, },
+ [DarkMode] = { { .i = 1 }, },
[DefaultCharset] = { { .v = "UTF-8" }, },
[DiskCache] = { { .i = 1 }, },
[DNSPrefetch] = { { .i = 0 }, },
@@ -146,9 +147,6 @@ static Key keys[] = {
{ MODKEY, GDK_KEY_c, stop, { 0 } },
- { GDK_SHIFT_MASK, GDK_KEY_l, navigate, { .i = +1 } },
- { GDK_SHIFT_MASK, GDK_KEY_h, navigate, { .i = -1 } },
-
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
@@ -190,3 +188,7 @@ static Button buttons[] = {
{ OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
{ OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },
};
+
+#define HOMEPAGE "https://duckduckgo.com/"
+
+#define HOMEPAGE "https://duckduckgo.com/"
diff --git a/config.def.h.orig b/config.def.h.orig
@@ -1,11 +1,15 @@
/* modifier 0 means no modifier */
static int surfuseragent = 1; /* Append Surf version to default WebKit user agent */
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 = "~/.cache/surf/certificates/";
static char *cachedir = "~/.cache/surf/cache/";
static char *cookiefile = "~/.cache/surf/cookies.txt";
+static char *scriptfiles[] = {
+ "~/.config/surf/scripts/script.js",
+ "~/.config/surf/scripts/link_hints.js",
+ "~/.config/surf/scripts/easier_key.js",
+};
/* Webkit default features */
/* Highest priority value will be used.
@@ -20,7 +24,7 @@ static Parameter defconfig[ParameterLast] = {
[Certificate] = { { .i = 0 }, },
[CaretBrowsing] = { { .i = 0 }, },
[CookiePolicies] = { { .v = "@Aa" }, },
- [DarkMode] = { { .i = 0 }, },
+ [DarkMode] = { { .i = 1 }, },
[DefaultCharset] = { { .v = "UTF-8" }, },
[DiskCache] = { { .i = 1 }, },
[DNSPrefetch] = { { .i = 0 }, },
@@ -51,9 +55,11 @@ static Parameter defconfig[ParameterLast] = {
};
static UriParameters uriparams[] = {
+/*
{ "(://|\\.)suckless\\.org(/|$)", {
[JavaScript] = { { .i = 0 }, 1 },
}, },
+*/
};
/* default window size: width, height */
@@ -119,7 +125,9 @@ static SiteSpecific styles[] = {
*/
static SiteSpecific certs[] = {
/* regexp file in $certdir */
+/*
{ "://suckless\\.org/", "suckless.org.crt" },
+*/
};
#define MODKEY GDK_CONTROL_MASK
@@ -132,37 +140,20 @@ static SiteSpecific certs[] = {
static Key keys[] = {
/* modifier keyval function arg */
{ MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
- { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
{ MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
{ MODKEY, GDK_KEY_w, playexternal, { 0 } },
- { 0, GDK_KEY_Escape, stop, { 0 } },
{ MODKEY, GDK_KEY_c, stop, { 0 } },
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
- { MODKEY, GDK_KEY_r, reload, { .i = 0 } },
-
- { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
- { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
-
- /* vertical and horizontal scrolling, in viewport percentage */
- { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } },
- { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } },
- { MODKEY, GDK_KEY_space, scrollv, { .i = +50 } },
- { MODKEY, GDK_KEY_b, scrollv, { .i = -50 } },
- { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } },
- { MODKEY, GDK_KEY_u, scrollh, { .i = -10 } },
-
-
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
{ MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
{ MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
- { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } },
- { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, clipboard, { .i = 1 } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_y, clipboard, { .i = 0 } },
{ MODKEY, GDK_KEY_n, find, { .i = +1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
@@ -196,3 +187,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/config.diff b/config.diff
@@ -1,61 +0,0 @@
---- config.def.h 2021-08-12 09:55:15.980353000 +0900
-+++ config.h 2021-08-10 11:04:40.573740000 +0900
-@@ -119,7 +119,8 @@
- { "://suckless\\.org/", "suckless.org.crt" },
- };
-
--#define MODKEY GDK_CONTROL_MASK
-+/*#define MODKEY GDK_CONTROL_MASK*/
-+#define MODKEY GDK_MOD1_MASK
-
- /* hotkeys */
- /*
-@@ -129,25 +130,27 @@
- static Key keys[] = {
- /* modifier keyval function arg */
- { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
-- { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
- { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
-
-+ { MODKEY, GDK_KEY_w, playexternal, { 0 } },
-+
- { 0, GDK_KEY_Escape, stop, { 0 } },
-- { MODKEY, GDK_KEY_c, stop, { 0 } },
-
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
- { MODKEY, GDK_KEY_r, reload, { .i = 0 } },
-
-- { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
-- { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
-+ { GDK_SHIFT_MASK, GDK_KEY_l, navigate, { .i = +1 } },
-+ { GDK_SHIFT_MASK, GDK_KEY_h, navigate, { .i = -1 } },
-
- /* vertical and horizontal scrolling, in viewport percentage */
-- { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } },
-- { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } },
-- { MODKEY, GDK_KEY_space, scrollv, { .i = +50 } },
-- { MODKEY, GDK_KEY_b, scrollv, { .i = -50 } },
-- { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } },
-- { MODKEY, GDK_KEY_u, scrollh, { .i = -10 } },
-+ { MODKEY, GDK_KEY_j, scrollv, { .i = +5 } },
-+ { MODKEY, GDK_KEY_e, scrollv, { .i = +5 } },
-+ { MODKEY, GDK_KEY_k, scrollv, { .i = -5 } },
-+ { MODKEY, GDK_KEY_y, scrollv, { .i = -5 } },
-+ { MODKEY, GDK_KEY_d, scrollv, { .i = +50 } },
-+ { MODKEY, GDK_KEY_u, scrollv, { .i = -50 } },
-+ { MODKEY, GDK_KEY_l, scrollh, { .i = +5 } },
-+ { MODKEY, GDK_KEY_h, scrollh, { .i = -5 } },
-
-
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
-@@ -156,8 +159,8 @@
- { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
- { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
-
-- { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } },
-- { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } },
-+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, clipboard, { .i = 1 } },
-+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_y, clipboard, { .i = 0 } },
-
- { MODKEY, GDK_KEY_n, find, { .i = +1 } },
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
diff --git a/config.h b/config.h
@@ -10,6 +10,7 @@ static char *scriptfiles[] = {
"~/.config/surf/scripts/link_hints.js",
"~/.config/surf/scripts/easier_key.js",
};
+static char *homepage = "file:///home/kenji/.config/surf/home.html";
/* Webkit default features */
/* Highest priority value will be used.
@@ -24,7 +25,7 @@ static Parameter defconfig[ParameterLast] = {
[Certificate] = { { .i = 0 }, },
[CaretBrowsing] = { { .i = 0 }, },
[CookiePolicies] = { { .v = "@Aa" }, },
- [DarkMode] = { { .i = 0 }, },
+ [DarkMode] = { { .i = 1 }, },
[DefaultCharset] = { { .v = "UTF-8" }, },
[DiskCache] = { { .i = 1 }, },
[DNSPrefetch] = { { .i = 0 }, },
@@ -146,11 +147,6 @@ static Key keys[] = {
{ MODKEY, GDK_KEY_c, stop, { 0 } },
- { GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
-
- { GDK_SHIFT_MASK, GDK_KEY_l, navigate, { .i = +1 } },
- { GDK_SHIFT_MASK, GDK_KEY_h, navigate, { .i = -1 } },
-
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
@@ -160,8 +156,8 @@ static Key keys[] = {
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, clipboard, { .i = 1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_y, clipboard, { .i = 0 } },
- { 0, GDK_KEY_n, find, { .i = +1 } },
- { GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
+ { MODKEY, GDK_KEY_n, find, { .i = +1 } },
+ { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
{ MODKEY, GDK_KEY_t, showcert, { 0 } },
@@ -192,3 +188,7 @@ static Button buttons[] = {
{ OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
{ OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },
};
+
+#define HOMEPAGE "https://duckduckgo.com/"
+
+#define HOMEPAGE "https://duckduckgo.com/"
diff --git a/surf b/surf
Binary files differ.
diff --git a/surf.c b/surf.c
@@ -2150,7 +2150,8 @@ main(int argc, char *argv[])
if (argc > 0)
arg.v = argv[0];
else
- arg.v = "about:blank";
+ //arg.v = "about:blank";
+ arg.v = homepage;
setup();
c = newclient(NULL);
diff --git a/surf.c.orig b/surf.c.orig
@@ -354,8 +354,10 @@ setup(void)
/* dirs and files */
cookiefile = buildfile(cookiefile);
- scriptfile = buildfile(scriptfile);
certdir = buildpath(certdir);
+ for (i = 0; i < LENGTH(scriptfiles); i++) {
+ scriptfiles[i] = buildfile(scriptfiles[i]);
+ }
if (curconfig[Ephemeral].val.i)
cachedir = NULL;
else
@@ -965,9 +967,11 @@ runscript(Client *c)
gchar *script;
gsize l;
- if (g_file_get_contents(scriptfile, &script, &l, NULL) && l)
- evalscript(c, "%s", script);
- g_free(script);
+ for (int i = 0; i < LENGTH(scriptfiles); i++) {
+ if (g_file_get_contents(scriptfiles[i], &script, &l, NULL) && l)
+ evalscript(c, "%s", script);
+ g_free(script);
+ }
}
void
@@ -1029,9 +1033,9 @@ newwindow(Client *c, const Arg *a, int noembed)
cmd[i++] = curconfig[KioskMode].val.i ? "-K" : "-k" ;
cmd[i++] = curconfig[Style].val.i ? "-M" : "-m" ;
cmd[i++] = curconfig[Inspector].val.i ? "-N" : "-n" ;
- if (scriptfile && g_strcmp0(scriptfile, "")) {
+ if (scriptfiles[0] && g_strcmp0(scriptfiles[0], "")) {
cmd[i++] = "-r";
- cmd[i++] = scriptfile;
+ cmd[i++] = scriptfiles[0];
}
cmd[i++] = curconfig[JavaScript].val.i ? "-S" : "-s";
cmd[i++] = curconfig[StrictTLS].val.i ? "-T" : "-t";
@@ -1095,9 +1099,12 @@ cleanup(void)
close(spair[0]);
close(spair[1]);
g_free(cookiefile);
- g_free(scriptfile);
g_free(stylefile);
g_free(cachedir);
+ for (int i = 0; i < LENGTH(scriptfiles); i++) {
+ g_free(scriptfiles[i]);
+ }
+
XCloseDisplay(dpy);
}
@@ -2099,7 +2106,7 @@ main(int argc, char *argv[])
defconfig[Inspector].prio = 2;
break;
case 'r':
- scriptfile = EARGF(usage());
+ scriptfiles[0] = EARGF(usage());
break;
case 's':
defconfig[JavaScript].val.i = 0;
@@ -2143,7 +2150,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);
diff --git a/surf.o b/surf.o
Binary files differ.
diff --git a/webext-surf.o b/webext-surf.o
Binary files differ.
diff --git a/webext-surf.so b/webext-surf.so
Binary files differ.