Skip to content

Commit

Permalink
build update
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhadityaMukherjee committed Dec 31, 2020
1 parent 80207aa commit c77c811
Show file tree
Hide file tree
Showing 12 changed files with 359 additions and 89 deletions.
2 changes: 2 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ static Key keys[] = {
{ MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
{ MODKEY, GDK_KEY_m, spawn, BM_ADD("_SURF_URI") },

{ MODKEY, GDK_KEY_w, playexternal, { 0 } },

{ 0, GDK_KEY_Escape, stop, { 0 } },
{ MODKEY, GDK_KEY_c, stop, { 0 } },

Expand Down
11 changes: 10 additions & 1 deletion config.def.h.orig
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
} \
}

#define SELNAV { \
.v = (char *[]){ "/bin/sh", "-c", \
"prop=\"`xprop -id $0 _SURF_HIST" \
" | sed -e 's/^.[^\"]*\"//' -e 's/\"$//' -e 's/\\\\\\n/\\n/g'" \
" | dmenu -i -l 10`\"" \
" && xprop -id $0 -f _SURF_NAV 8s -set _SURF_NAV \"$prop\"", \
winid, NULL \
} \
}

/* DOWNLOAD(URI, referer) */
#define DOWNLOAD(u, r) { \
.v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
Expand Down Expand Up @@ -161,7 +171,6 @@ static Key keys[] = {

{ 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 } },
Expand Down
2 changes: 2 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ static Key keys[] = {
{ MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
{ MODKEY, GDK_KEY_m, spawn, BM_ADD("_SURF_URI") },

{ MODKEY, GDK_KEY_w, playexternal, { 0 } },

{ 0, GDK_KEY_Escape, stop, { 0 } },
{ MODKEY, GDK_KEY_c, stop, { 0 } },

Expand Down
Binary file modified surf
Binary file not shown.
56 changes: 56 additions & 0 deletions surf-git-20170323-webkit2-searchengines.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/surf.c b/surf.c
index 93a1629..eb2af97 100644
--- a/surf.c
+++ b/surf.c
@@ -129,6 +129,11 @@ typedef struct {
} Button;

typedef struct {
+ char *token;
+ char *uri;
+} SearchEngine;
+
+typedef struct {
const char *uri;
Parameter config[ParameterLast];
regex_t re;
@@ -202,6 +207,7 @@ static void responsereceived(WebKitDownload *d, GParamSpec *ps, Client *c);
static void download(Client *c, WebKitURIResponse *r);
static void closeview(WebKitWebView *v, Client *c);
static void destroywin(GtkWidget* w, Client *c);
+static gchar *parseuri(const gchar *uri);

/* Hotkeys */
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
@@ -477,7 +483,7 @@ loaduri(Client *c, const Arg *a)
url = g_strdup_printf("file://%s", path);
free(path);
} else {
- url = g_strdup_printf("http://%s", uri);
+ url = parseuri(uri);
}

setatom(c, AtomUri, url);
@@ -1461,6 +1467,22 @@ destroywin(GtkWidget* w, Client *c)
gtk_main_quit();
}

+gchar *
+parseuri(const gchar *uri) {
+ guint i;
+
+ for (i = 0; i < LENGTH(searchengines); i++) {
+ if (searchengines[i].token == NULL || searchengines[i].uri == NULL ||
+ *(uri + strlen(searchengines[i].token)) != ' ')
+ continue;
+ if (g_str_has_prefix(uri, searchengines[i].token))
+ return g_strdup_printf(searchengines[i].uri,
+ uri + strlen(searchengines[i].token) + 1);
+ }
+
+ return g_strdup_printf("http://%s", uri);
+}
+
void
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
{
54 changes: 54 additions & 0 deletions surf-playexternal-20190724-b814567.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
From 95e17b5bd428173c83e60cec9cd5666cfe9066fa Mon Sep 17 00:00:00 2001
From: DanMan <dnahimov@gmail.com>
Date: Wed, 24 Jul 2019 18:47:46 -0400
Subject: [PATCH] added playexternal hotkey function

---
config.def.h | 2 ++
surf.c | 10 ++++++++++
2 files changed, 12 insertions(+)

diff --git a/config.def.h b/config.def.h
index 6d3135e..5fa0d9d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -105,6 +105,8 @@ static Key keys[] = {
{ MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },
{ MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") },

+ { MODKEY, GDK_KEY_w, playexternal, { 0 } },
+
{ 0, GDK_KEY_Escape, stop, { 0 } },
{ MODKEY, GDK_KEY_c, stop, { 0 } },

diff --git a/surf.c b/surf.c
index 93a1629..e74e9df 100644
--- a/surf.c
+++ b/surf.c
@@ -217,6 +217,7 @@ static void togglefullscreen(Client *c, const Arg *a);
static void togglecookiepolicy(Client *c, const Arg *a);
static void toggleinspector(Client *c, const Arg *a);
static void find(Client *c, const Arg *a);
+static void playexternal(Client *c, const Arg *a);

/* Buttons */
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
@@ -1648,6 +1649,15 @@ clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h)
spawn(c, &arg);
}

+void
+playexternal(Client *c, const Arg *a)
+{
+ Arg arg;
+
+ arg = (Arg)VIDEOPLAY(geturi(c));
+ spawn(c, &arg);
+}
+
int
main(int argc, char *argv[])
{
--
2.22.0

35 changes: 35 additions & 0 deletions surf-scrollmultiply-2.0.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff -up surf-2.0/surf.c surf/surf.c
--- surf-2.0/surf.c 2018-04-13 10:55:11.036959113 +0200
+++ surf/surf.c 2018-04-14 12:12:41.519989478 +0200
@@ -179,6 +179,8 @@ static void initwebextensions(WebKitWebC
static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a,
Client *c);
static gboolean buttonreleased(GtkWidget *w, GdkEvent *e, Client *c);
+static gboolean scrollmultiply(GtkWidget *w, GdkEvent *e, Client *c);
+
static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event,
gpointer d);
static gboolean winevent(GtkWidget *w, GdkEvent *e, Client *c);
@@ -1152,6 +1154,8 @@ newview(Client *c, WebKitWebView *rv)
G_CALLBACK(titlechanged), c);
g_signal_connect(G_OBJECT(v), "button-release-event",
G_CALLBACK(buttonreleased), c);
+ g_signal_connect(G_OBJECT(v), "scroll-event",
+ G_CALLBACK(scrollmultiply), c);
g_signal_connect(G_OBJECT(v), "close",
G_CALLBACK(closeview), c);
g_signal_connect(G_OBJECT(v), "create",
@@ -1229,6 +1233,13 @@ buttonreleased(GtkWidget *w, GdkEvent *e
return FALSE;
}

+gboolean
+scrollmultiply(GtkWidget *w, GdkEvent *e, Client *c)
+{
+ e->scroll.delta_y*=7;
+ return FALSE;
+}
+
GdkFilterReturn
processx(GdkXEvent *e, GdkEvent *event, gpointer d)
{
107 changes: 107 additions & 0 deletions surf-websearch-20190510-d068a38.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
From c5ca896c5ba969b90f1e098d117c205a9b71d0db Mon Sep 17 00:00:00 2001
From: Bryon Meinka <bryon.meinka@gmail.com>
Date: Sat, 11 May 2019 00:52:29 -0400
Subject: [PATCH] Web Search

---
config.def.h | 10 ++++++++++
surf.c | 20 +++++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/config.def.h b/config.def.h
index 34265f6..69657bf 100644
--- a/config.def.h
+++ b/config.def.h
@@ -6,6 +6,7 @@ static char *styledir = "~/.surf/styles/";
static char *certdir = "~/.surf/certificates/";
static char *cachedir = "~/.surf/cache/";
static char *cookiefile = "~/.surf/cookies.txt";
+static char *searchurl = "duckduckgo.com/?q=%s";

/* Webkit default features */
/* Highest priority value will be used.
@@ -76,6 +77,14 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
} \
}

+#define SEARCH() { \
+ .v = (const char *[]){ "/bin/sh", "-c", \
+ "xprop -id $1 -f $2 8s -set $2 \"" \
+ "$(dmenu -p Search: -w $1 < /dev/null)\"", \
+ "surf-search", winid, "_SURF_SEARCH", NULL \
+ } \
+}
+
/* DOWNLOAD(URI, referer) */
#define DOWNLOAD(u, r) { \
.v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
@@ -133,6 +142,7 @@ static Key keys[] = {
{ 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_s, spawn, SEARCH() },

{ 0, GDK_KEY_Escape, stop, { 0 } },
{ MODKEY, GDK_KEY_c, stop, { 0 } },
diff --git a/surf.c b/surf.c
index 2b54e3c..077fb76 100644
--- a/surf.c
+++ b/surf.c
@@ -35,7 +35,7 @@
#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))

-enum { AtomFind, AtomGo, AtomUri, AtomLast };
+enum { AtomFind, AtomSearch, AtomGo, AtomUri, AtomLast };

enum {
OnDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT,
@@ -231,6 +231,7 @@ static void togglefullscreen(Client *c, const Arg *a);
static void togglecookiepolicy(Client *c, const Arg *a);
static void toggleinspector(Client *c, const Arg *a);
static void find(Client *c, const Arg *a);
+static void search(Client *c, const Arg *a);

/* Buttons */
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
@@ -326,6 +327,7 @@ setup(void)

/* atoms */
atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
+ atoms[AtomSearch] = XInternAtom(dpy, "_SURF_SEARCH", False);
atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False);
atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False);

@@ -577,6 +579,19 @@ loaduri(Client *c, const Arg *a)
g_free(url);
}

+void
+search(Client *c, const Arg *a)
+{
+ Arg arg;
+ char *url;
+
+ url = g_strdup_printf(searchurl, a->v);
+ arg.v = url;
+ loaduri(c, &arg);
+
+ g_free(url);
+}
+
const char *
geturi(Client *c)
{
@@ -1311,6 +1326,9 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d)
find(c, NULL);

return GDK_FILTER_REMOVE;
+ } else if (ev->atom == atoms[AtomSearch]) {
+ a.v = getatom(c, AtomSearch);
+ search(c, &a);
} else if (ev->atom == atoms[AtomGo]) {
a.v = getatom(c, AtomGo);
loaduri(c, &a);
--
2.21.0

Loading

0 comments on commit c77c811

Please sign in to comment.