[wiki] [sites] Update surf searchengies and surf bookmarks || blut

From: <git_AT_suckless.org>
Date: Tue, 14 May 2013 21:48:14 +0200

commit 8b25649cfd09177ca3ffada90870642a18fc9502
Author: blut <blut.hannes_AT_gmail.com>
Date: Tue May 14 21:47:51 2013 +0200

    Update surf searchengies and surf bookmarks

diff --git a/surf.suckless.org/patches/bookmarking.md b/surf.suckless.org/patches/bookmarking.md
new file mode 100644
index 0000000..b959746
--- /dev/null
+++ b/surf.suckless.org/patches/bookmarking.md
_AT_@ -0,0 +1,20 @@
+Simple bookmarking
+==================
+
+Description
+-----------
+
+Uses cat to add all strings from ~/.surf/bookmarks to the input dmenu.
+Ctrl-b is used to add a new bookmark.
+
+Download
+--------
+
+* [surf-0.6-bookmarks.diff](surf-0.6-bookmarks.diff) (20130514)
+
+Author
+------
+stolen from
+- Julien Steinhauser <[julien.steinhauser_AT_orange.fr](mailto:julien.steinhauser_AT_orange.fr)>
+written into a patch
+- blut
diff --git a/surf.suckless.org/patches/searchengines.md b/surf.suckless.org/patches/searchengines.md
index 31e310c..3afefd4 100644
--- a/surf.suckless.org/patches/searchengines.md
+++ b/surf.suckless.org/patches/searchengines.md
_AT_@ -21,6 +21,8 @@ or:
 
         leo hello
 
+0.6 patch patches the searchengines array into the config.def.h file.
+
 Download
 --------
 
_AT_@ -28,6 +30,7 @@ Download
 * [surf-0.3-searchengines.diff](surf-0.3-searchengines.diff) (2107) (20091204)
 * [surf-0.4-searchengines.diff](surf-0.4-searchengines.diff) (2107) (20091204)
 * [surf-0.5-searchengines.diff](surf-0.5-searchengines.diff) (1611) (20101028)
+* [surf-0.6-searchengines.diff](surf-0.6-searchengines.diff) (20130514)
 
 Author
 ------
diff --git a/surf.suckless.org/patches/surf-0.6-bookmarks.diff b/surf.suckless.org/patches/surf-0.6-bookmarks.diff
new file mode 100644
index 0000000..d07a325
--- /dev/null
+++ b/surf.suckless.org/patches/surf-0.6-bookmarks.diff
_AT_@ -0,0 +1,40 @@
+diff --git a/config.def.h b/config.def.h
+index 08ff707..8185136 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -25,7 +25,8 @@ static Bool allowgeolocation = TRUE;
+
+ #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 | cut -d '\"' -f 2 | xargs -0 printf %b && "\
++ "cat ~/.surf/bookmarks) | dmenu`\" &&" \
+ "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
+ p, q, winid, NULL \
+ } \
+_AT_@ -41,6 +42,12 @@ static Bool allowgeolocation = TRUE;
+ } \
+ }
+
++#define BM_ADD { .v = (char *[]){ "/bin/sh", "-c", \
++ "(echo `xprop -id $0 _SURF_URI | cut -d '\"' -f 2` && \
++ cat ~/.surf/bookmarks) > ~/.surf/bookmarks_new && \
++ mv ~/.surf/bookmarks_new ~/.surf/bookmarks", \
++ winid, NULL } }
++
+ #define MODKEY GDK_CONTROL_MASK
+
+ /* hotkeys */
+_AT_@ -72,6 +79,7 @@ static Key keys[] = {
+ { MODKEY, GDK_space, scroll_v, { .i = +10000 } },
+ { MODKEY, GDK_i, scroll_h, { .i = +1 } },
+ { MODKEY, GDK_u, scroll_h, { .i = -1 } },
++ { MODKEY, GDK_b, spawn, BM_ADD },
+
+ { 0, GDK_F11, fullscreen, { 0 } },
+ { 0, GDK_Escape, stop, { 0 } },
+_AT_@ -93,4 +101,3 @@ static Key keys[] = {
+ { MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars,{ 0 } },
+ { MODKEY|GDK_SHIFT_MASK,GDK_g, togglegeolocation, { 0 } },
+ };
+-
diff --git a/surf.suckless.org/patches/surf-0.6-searchengines.diff b/surf.suckless.org/patches/surf-0.6-searchengines.diff
new file mode 100644
index 0000000..653453d
--- /dev/null
+++ b/surf.suckless.org/patches/surf-0.6-searchengines.diff
_AT_@ -0,0 +1,71 @@
+diff --git a/config.def.h b/config.def.h
+index 8185136..6b5144c 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -101,3 +101,10 @@ static Key keys[] = {
+ { MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars,{ 0 } },
+ { MODKEY|GDK_SHIFT_MASK,GDK_g, togglegeolocation, { 0 } },
+ };
++
++static SearchEngine searchengines[] = {
++ { "g", "http://www.google.de/search?q=%s" },
++ { "en", "http://dict.cc/?s=%s" },
++ { "ug", "http://%s.uni-goettingen.de" },
++ { "dict", "http://www.thefreedictionary.com/%s" },
++};
+diff --git a/surf.c b/surf.c
+index da84e1c..7eff5e8 100644
+--- a/surf.c
++++ b/surf.c
+_AT_@ -70,6 +70,11 @@ typedef struct {
+
+ G_DEFINE_TYPE(CookieJar, cookiejar, SOUP_TYPE_COOKIE_JAR_TEXT)
+
++typedef struct {
++ char *token;
++ char *uri;
++} SearchEngine;
++
+ static Display *dpy;
+ static Atom atoms[AtomLast];
+ static Client *clients = NULL;
+_AT_@ -140,6 +145,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 void populatepopup(WebKitWebView *web, GtkMenu *menu, Client *c);
+ static void popupactivate(GtkMenuItem *menu, Client *);
+_AT_@ -629,8 +635,8 @@ 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);
++
+ }
+
+ /* prevents endless loop */
+_AT_@ -911,6 +917,20 @@ popupactivate(GtkMenuItem *menu, Client *c) {
+ }
+ }
+
++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 };
Received on Tue May 14 2013 - 21:48:14 CEST

This archive was generated by hypermail 2.3.0 : Tue May 14 2013 - 22:00:12 CEST