commit 02cad9030554b2549d0d4fba9d4f645de6d5a205
Author: Ivan Tham <[email protected]>
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
@@ -17,3 +17,4 @@ Author
 
 * Matthew Bauer <[[email protected]](mailto:[email protected])>
 * Henrique Lengler 
<[[email protected]](mailto:[email protected])>
+* Ivan Tham <[[email protected]](mailto:[email protected])>
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
@@ -38,3 +38,4 @@ Author
 * Nils Schweinsberg (McManiaC) <[[email protected]](mailto:[email protected])>
 * Samuel Baldwin (shardz) 
<[[email protected]](mailto:[email protected])>
 * Alex Puterbaugh (zombine) 
<[[email protected]](mailto:[email protected])>
+* Ivan Tham (pickfire) <[[email protected]](mailto:[email protected])>
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
@@ -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
 @@ -35,6 +35,7 @@ static Bool loadimages            = TRUE;
@@ -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
-@@ -1645,6 +1645,9 @@ main(int argc, char *argv[]) {
+@@ -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
@@ -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
-@@ -92,6 +92,12 @@ typedef struct {
- G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
+@@@ -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,
+@@@ -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
+@@ -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;
-@@ -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);
-@@ -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);
-@@ -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 */


Reply via email to