sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 02cad9030554b2549d0d4fba9d4f645de6d5a205
parent ccd3815d2a83f17488be3c42ec1586b24652c5eb
Author: Ivan Tham <pickfire@riseup.net>
Date:   Thu, 17 Dec 2015 18:25:32 +0800

[surf] Update homepage and searchengines patch

Diffstat:
Msurf.suckless.org/patches/homepage.md | 1+
Msurf.suckless.org/patches/searchengines.md | 1+
Msurf.suckless.org/patches/surf-0.6-homepage.diff | 10+++++-----
Msurf.suckless.org/patches/surf-0.6-searchengines.diff | 112++++++++++++++++++++++++++++++++++++++++++-------------------------------------
4 files changed, 67 insertions(+), 57 deletions(-)

diff --git a/surf.suckless.org/patches/homepage.md b/surf.suckless.org/patches/homepage.md @@ -17,3 +17,4 @@ Author * Matthew Bauer <[mjbauer95@gmail.com](mailto:mjbauer95@gmail.com)> * Henrique Lengler <[henriqueleng@openmailbox.org](mailto:henriqueleng@openmailbox.org)> +* Ivan Tham <[pickfire@riseup.net](mailto:pickfire@riseup.net)> diff --git a/surf.suckless.org/patches/searchengines.md b/surf.suckless.org/patches/searchengines.md @@ -38,3 +38,4 @@ Author * Nils Schweinsberg (McManiaC) <[mail@n-sch.de](mailto:mail@n-sch.de)> * Samuel Baldwin (shardz) <[recursive.forest@gmail.com](mailto:recursive.forest@gmail.com)> * Alex Puterbaugh (zombine) <[puterbaugh0@gmail.com](mailto:puterbaugh0@gmail.com)> +* Ivan Tham (pickfire) <[pickfire@riseup.net](mailto:pickfire@riseup.net)> diff --git 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 @@ -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 */