aboutsummaryrefslogtreecommitdiffstats
path: root/config.def.h
diff options
context:
space:
mode:
authorAlexander Leonhardt <equinox.salexander@gmail.com>
2026-08-03 00:51:21 +0200
committerAlexander Leonhardt <equinox.salexander@gmail.com>
2026-08-03 00:51:21 +0200
commit8c2b6a684a3d054cfa5ef0bc48641ca19650f4f5 (patch)
treea506b1d24be827b7c45eec8b4fe35ff24755425e /config.def.h
parent0f7f59a5071b82bbd1fb7845538cf93ed54b5afe (diff)
downloadsurf-8c2b6a684a3d054cfa5ef0bc48641ca19650f4f5.tar.gz
surf-8c2b6a684a3d054cfa5ef0bc48641ca19650f4f5.tar.bz2
surf-8c2b6a684a3d054cfa5ef0bc48641ca19650f4f5.zip
Added the latest changes
Diffstat (limited to 'config.def.h')
-rw-r--r--config.def.h92
1 files changed, 67 insertions, 25 deletions
diff --git a/config.def.h b/config.def.h
index 9b0f6f6..e4fc503 100644
--- a/config.def.h
+++ b/config.def.h
@@ -6,6 +6,9 @@ static char *styledir = "~/.surf/styles/";
static char *certdir = "~/.surf/certificates/";
static char *cachedir = "~/.surf/cache/";
static char *cookiefile = "~/.surf/cookies.txt";
+/* a macro too, the GO() shell command below needs it as a constant */
+#define HISTFILE "~/.surf/history"
+static char *histfile = HISTFILE;
/* Webkit default features */
/* Highest priority value will be used.
@@ -20,7 +23,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 }, },
@@ -46,7 +49,7 @@ static Parameter defconfig[ParameterLast] = {
[StrictTLS] = { { .i = 1 }, },
[Style] = { { .i = 1 }, },
[WebGL] = { { .i = 0 }, },
- [ZoomLevel] = { { .f = 1.0 }, },
+ [ZoomLevel] = { { .f = 1.4 }, },
};
static UriParameters uriparams[] = {
@@ -62,20 +65,48 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
WEBKIT_FIND_OPTIONS_WRAP_AROUND;
#define PROMPT_GO "Go:"
+#define PROMPT_GO_TAB "Go(TAB):"
+#define PROMPT_SEARCH "Search:"
#define PROMPT_FIND "Find:"
-/* SETPROP(readprop, setprop, prompt)*/
-#define SETPROP(r, s, p) { \
+/* SETPROP(command, current value, prompt) */
+/* Prompts for a value and writes "command value" to the control fifo of the
+ * window the key was pressed in, see initctl() in surf.c. */
+#define SETPROP(cmd, cur, prompt) { \
.v = (const char *[]){ "/bin/sh", "-c", \
- "prop=\"$(printf '%b' \"$(xprop -id $1 "r" " \
- "| sed -e 's/^"r"(UTF8_STRING) = \"\\(.*\\)\"/\\1/' " \
- " -e 's/\\\\\\(.\\)/\\1/g')\" " \
- "| dmenu -p '"p"' -w $1)\" " \
- "&& xprop -id $1 -f "s" 8u -set "s" \"$prop\"", \
- "surf-setprop", winid, NULL \
+ "val=\"$(printf '%s' \"$3\" | wmenu -bi -l 25 -M aa00aa -m 000000 -S aa00aa -s 000000 -p \"$4\")\" " \
+ "&& printf '%s %s\\n' \"$2\" \"$val\" >\"$1\"", \
+ "surf-setprop", winid, cmd, cur, prompt, NULL \
} \
}
+/* GO(prompt) */
+/* Prompts for a URI, offering the current one first and then the history
+ * ranked by visit count. Drop the sort pipeline for a plain prompt. */
+#define GO(prompt) { \
+ .v = (const char *[]){ "/bin/sh", "-c", \
+ "val=\"$({ printf '%s\\n' \"$3\"; " \
+ "sort " HISTFILE " | uniq -c | sort -rn | sed 's/^ *[0-9]* //'; } " \
+ "| awk '!seen[$0]++' | wmenu -bi -l 25 -S aa00aa -s 000000 -M aa00aa -m 000000 -p \"$4\")\" " \
+ "&& printf '%s %s\\n' \"$2\" \"$val\" >\"$1\"", \
+ "surf-go", winid, "uri", winuri, prompt, NULL \
+ } \
+}
+
+/* GO_TAB(prompt) */
+/* Prompts for a URI, offering the current one first and then the history
+ * ranked by visit count. Drop the sort pipeline for a plain prompt. */
+#define GO_TAB(prompt) { \
+ .v = (const char *[]){ "/bin/sh", "-c", \
+ "val=\"$({ printf '%s\\n' \"$1\"; " \
+ "sort " HISTFILE " | uniq -c | sort -rn | sed 's/^ *[0-9]* //'; } " \
+ "| awk '!seen[$0]++' | wmenu -bi -l 25 -S aa00aa -s 000000 -M aa00aa -m 000000 -p \"$2\")\" " \
+ "&& surf \"$val\"", \
+ "surf", winuri, prompt, NULL \
+ } \
+}
+
+
/* DOWNLOAD(URI, referer) */
#define DOWNLOAD(u, r) { \
.v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
@@ -95,6 +126,23 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
} \
}
+
+#define COPYURL() {\
+ .v = (const char *[]){ "/bin/sh", "-c", \
+ "printf '%s' \"$0\" | wl-copy", winuri , NULL \
+ } \
+}
+
+#define SEARCH(u) {\
+ .v = (const char *[]){ "/bin/sh", "-c", \
+ "val=\"$(echo \"\" | wmenu -bi -S aa00aa -s 000000 -M aa00aa -m 000000 -p \"$4\")\" " \
+ "&& printf '%s %s\\n' \"$2\" \"https://www.google.com/search?q=$val\" >\"$1\"", \
+ "surf-go", winid, "uri", winuri, u, NULL \
+ } \
+}
+
+
+
/* VIDEOPLAY(URI) */
#define VIDEOPLAY(u) {\
.v = (const char *[]){ "/bin/sh", "-c", \
@@ -130,12 +178,13 @@ 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_g, spawn, GO(PROMPT_GO) },
+ { MODKEY, GDK_KEY_f, spawn, SETPROP("find", winfind, PROMPT_FIND) },
+ { MODKEY, GDK_KEY_slash, spawn, SETPROP("find", winfind, PROMPT_FIND) },
{ 0, GDK_KEY_Escape, stop, { 0 } },
- { MODKEY, GDK_KEY_c, stop, { 0 } },
+ { MODKEY, GDK_KEY_e, spawn, COPYURL() },
+ { MODKEY, GDK_KEY_s, spawn, SEARCH(PROMPT_SEARCH) },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
{ MODKEY, GDK_KEY_r, reload, { .i = 0 } },
@@ -165,19 +214,12 @@ static Key keys[] = {
{ 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 } },
+ { MODKEY, GDK_KEY_t, spawn, GO_TAB(PROMPT_GO_TAB) },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
{ 0, GDK_KEY_F11, togglefullscreen, { 0 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } },
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } },
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } },
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } },
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } },
- { 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_SHIFT_MASK, GDK_KEY_d, toggle, { .i = DarkMode } },
};
@@ -185,9 +227,9 @@ static Key keys[] = {
/* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
static Button buttons[] = {
/* target event mask button function argument stop event */
- { OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 },
- { OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 },
- { OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 },
+ { OnLink, 0, 2, clicknewwindow, { 0 }, 1 },
+ { OnLink, MODKEY, 2, clicknewwindow, { 0 }, 1 },
+ { OnLink, MODKEY, 1, clicknewwindow, { 0 }, 1 },
{ OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
{ OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
{ OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },