[wiki] [sites] [surf] Update homepage and searchengines patch || Ivan Tham

From: <git_AT_suckless.org>
Date: Thu, 17 Dec 2015 11:25:37 +0100

commit 02cad9030554b2549d0d4fba9d4f645de6d5a205
Author: Ivan Tham <pickfire_AT_riseup.net>
Date: Thu Dec 17 18:25:32 2015 +0800

    [surf] Update homepage and searchengines patch

diff --git a/surf.suckless.org/patches/homepage.md b/surf.suckless.org/patches/homepage.md
index 995ab55..50f59c6 100644
--- a/surf.suckless.org/patches/homepage.md
+++ b/surf.suckless.org/patches/homepage.md
_AT_@ -17,3 +17,4 @@ Author
 
 * Matthew Bauer <[mjbauer95_AT_gmail.com](mailto:mjbauer95_AT_gmail.com)>
 * Henrique Lengler <[henriqueleng_AT_openmailbox.org](mailto:henriqueleng_AT_openmailbox.org)>
+* Ivan Tham <[pickfire_AT_riseup.net](mailto:pickfire_AT_riseup.net)>
diff --git a/surf.suckless.org/patches/searchengines.md b/surf.suckless.org/patches/searchengines.md
index 3afefd4..5ff2e1d 100644
--- a/surf.suckless.org/patches/searchengines.md
+++ b/surf.suckless.org/patches/searchengines.md
_AT_@ -38,3 +38,4 @@ Author
 * Nils Schweinsberg (McManiaC) <[mail_AT_n-sch.de](mailto:mail_AT_n-sch.de)>
 * Samuel Baldwin (shardz) <[recursive.forest_AT_gmail.com](mailto:recursive.forest_AT_gmail.com)>
 * Alex Puterbaugh (zombine) <[puterbaugh0_AT_gmail.com](mailto:puterbaugh0_AT_gmail.com)>
+* Ivan Tham (pickfire) <[pickfire_AT_riseup.net](mailto:pickfire_AT_riseup.net)>
diff --git a/surf.suckless.org/patches/surf-0.6-homepage.diff b/surf.suckless.org/patches/surf-0.6-homepage.diff
index 124377a..7f890bf 100644
--- a/surf.suckless.org/patches/surf-0.6-homepage.diff
+++ b/surf.suckless.org/patches/surf-0.6-homepage.diff
_AT_@ -1,5 +1,5 @@
 diff --git a/config.def.h b/config.def.h
-index 1eb9566..8dbd96b 100644
+index 93a3d49..41bb067 100644
 --- a/config.def.h
 +++ b/config.def.h
 _AT_@ -35,6 +35,7 @@ static Bool loadimages = TRUE;
_AT_@ -9,18 +9,18 @@ index 1eb9566..8dbd96b 100644
 +#define HOMEPAGE "https://www.duckduckgo.com/"
  #define SETPROP(p, q) { \
          .v = (char *[]){ "/bin/sh", "-c", \
- "prop=\"`xprop -id $2 $0 | cut -d '\"' -f 2 | xargs -0 printf %b | dmenu`\" &&" \
+ "prop=\"`xprop -id $2 $0 " \
 diff --git a/surf.c b/surf.c
-index 02656ec..c6a6806 100644
+index fdfaab1..7a71bf2 100644
 --- a/surf.c
 +++ b/surf.c
-_AT_@ -1645,6 +1645,9 @@ main(int argc, char *argv[]) {
+_AT_@ -1759,6 +1759,9 @@ main(int argc, char *argv[])
          default:
                  usage();
          } ARGEND;
 + #ifdef HOMEPAGE
 + arg.v = HOMEPAGE;
 + #endif
- if(argc > 0)
+ if (argc > 0)
                  arg.v = argv[0];
  
diff --git a/surf.suckless.org/patches/surf-0.6-searchengines.diff b/surf.suckless.org/patches/surf-0.6-searchengines.diff
index da1828f..d7325f2 100644
--- a/surf.suckless.org/patches/surf-0.6-searchengines.diff
+++ b/surf.suckless.org/patches/surf-0.6-searchengines.diff
_AT_@ -1,57 +1,65 @@
-diff --git a/surf.c b/surf.c
-index 0fae80b..deb23b7 100644
+diff --cc surf.c
+index fdfaab1,deb23b7..0000000
 --- a/surf.c
 +++ b/surf.c
-_AT_@ -92,6 +92,12 @@ typedef struct {
- G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
+_AT_@@ -178,10 -185,10 +184,11 @@@ static void loaduri(Client *c, const Ar
+ static void navigate(Client *c, const Arg *arg);
+ static Client *newclient(void);
+ static void newwindow(Client *c, const Arg *arg, gboolean noembed);
++ static gchar *parseuri(const gchar *uri);
+ static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
+ static gboolean contextmenu(WebKitWebView *view, GtkWidget *menu,
+ - WebKitHitTestResult *target, gboolean keyboard, Client *c);
+ + WebKitHitTestResult *target, gboolean keyboard,
+ + Client *c);
+ static void menuactivate(GtkMenuItem *item, Client *c);
+ static void print(Client *c, const Arg *arg);
+ static GdkFilterReturn processx(GdkXEvent *xevent, GdkEvent *event,
+_AT_@@ -1172,11 -1128,25 +1178,26 @@@ menuactivate(GtkMenuItem *item, Client
+ }
+ }
+
+- void
++ static 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_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("http://%s", uri);
++ }
++
++ static void
+ -pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
+ +pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
+ +{
+ Arg arg = {.v = text };
+ - if(text != NULL)
+ + if (text != NULL)
+ loaduri((Client *) d, &arg);
+ }
+
+diff --git a/config.def.h b/config.def.h
+index 93a3d49..4ac7f15 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -75,6 +75,13 @@ static SiteStyle styles[] = {
+ { ".*", "default.css" },
+ };
  
- typedef struct {
-+ char *token;
-+ char *uri;
-+} SearchEngine;
++/* search engines */
++static SearchEngine searchengines[] = {
++ { "g", "http://www.google.de/search?q=%s" },
++ { "leo", "http://dict.leo.org/ende?search=%s" },
++ { "ddg", "https://duckduckgo.com/?q=%s" },
++};
 +
-+
-+typedef struct {
- char *regex;
- char *style;
- regex_t re;
-_AT_@ -179,6 +185,7 @@ static void loaduri(Client *c, const Arg *arg);
- static void navigate(Client *c, const Arg *arg);
- static Client *newclient(void);
- static void newwindow(Client *c, const Arg *arg, gboolean noembed);
-+static gchar *parseuri(const gchar *uri);
- static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d);
- static gboolean contextmenu(WebKitWebView *view, GtkWidget *menu,
- WebKitHitTestResult *target, gboolean keyboard, Client *c);
-_AT_@ -789,8 +796,7 @@ loaduri(Client *c, const Arg *arg) {
- u = g_strdup_printf("file://%s", rp);
- free(rp);
- } else {
-- u = g_strrstr(uri, "://") ? g_strdup(uri)
-- : g_strdup_printf("http://%s", uri);
-+ u = parseuri(uri);
- }
-
- setatom(c, AtomUri, uri);
-_AT_@ -1122,6 +1128,21 @@ menuactivate(GtkMenuItem *item, Client *c) {
- }
- }
+ #define MODKEY GDK_CONTROL_MASK
  
-+static 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_strrstr(uri, "://") ? g_strdup(uri) : g_strdup_printf("http://%s", uri);
-+}
-+
- static void
- pasteuri(GtkClipboard *clipboard, const char *text, gpointer d) {
- Arg arg = {.v = text };
+ /* hotkeys */
Received on Thu Dec 17 2015 - 11:25:37 CET

This archive was generated by hypermail 2.3.0 : Thu Dec 17 2015 - 11:36:15 CET