commit b33bdf7afaf1bf67f3d98f4716f426920436475d
parent 0a42bb623e234cb6b6796cacf5544e57db32ab04
Author: Alexis Ben Miloud--Josselin <alexis.bmj@protonmail.com>
Date: Sat, 22 Jul 2017 22:11:56 +0200
[surf] update bookmarking patch
Diffstat:
2 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/surf.suckless.org/patches/bookmarking.md b/surf.suckless.org/patches/bookmarking.md
@@ -5,12 +5,13 @@ Description
-----------
Uses cat to add all strings from ~/.surf/bookmarks to the input dmenu.
-Ctrl-b is used to add a new bookmark.
+Ctrl-m is used to add a new bookmark.
Download
--------
-* [surf-0.6-bookmarks.diff](surf-0.6-bookmarks.diff) (20130514)
+* [surf-0.6-bookmarks.diff](surf-0.6-bookmarks.diff) (20130514) *Note: use Ctrl-b instead of Ctrl-m.*
+* [surf-bookmarks-20170722-723ff26.diff](surf-bookmarks-20170722-723ff26.diff) (20170722)
Author
------
@@ -18,3 +19,4 @@ stolen from
- Julien Steinhauser <[julien.steinhauser@orange.fr](mailto:julien.steinhauser@orange.fr)>
written into a patch
- blut
+- Alexis Ben Miloud--Josselin (panpo) <[alexis.bmj@protonmail.com](mailto:alexis.bmj@protonmail.com)>
diff --git a/surf.suckless.org/patches/surf-bookmarks-20170722-723ff26.diff b/surf.suckless.org/patches/surf-bookmarks-20170722-723ff26.diff
@@ -0,0 +1,42 @@
+diff --git a/config.def.h b/config.def.h
+index 2e735bf..43ad9ab 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -69,8 +69,9 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
+ #define SETPROP(r, s, p) { \
+ .v = (const char *[]){ "/bin/sh", "-c", \
+ "prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
+- "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \
+- "| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
++ "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\" && cat ~/.surf/bookmarks)\" " \
++ "| dmenu -l 10 -p \"$4\" -w $1)\" && " \
++ "xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
+ "surf-setprop", winid, r, s, p, NULL \
+ } \
+ }
+@@ -101,6 +102,17 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
+ } \
+ }
+
++/* BM_ADD(readprop) */
++#define BM_ADD(r) {\
++ .v = (const char *[]){ "/bin/sh", "-c", \
++ "(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \
++ "| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.surf/bookmarks) " \
++ "| awk '!seen[$0]++' > ~/.surf/bookmarks.tmp && " \
++ "mv ~/.surf/bookmarks.tmp ~/.surf/bookmarks", \
++ winid, r, NULL \
++ } \
++}
++
+ /* styles */
+ /*
+ * The iteration will stop at the first match, beginning at the beginning of
+@@ -132,6 +144,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_m, spawn, BM_ADD("_SURF_URI") },
+
+ { 0, GDK_KEY_Escape, stop, { 0 } },
+ { MODKEY, GDK_KEY_c, stop, { 0 } },