surf

surf
git clone git@git.zachrice.app:repos/surf.git
Log | Files | Refs | README | LICENSE

surf-bookmarks.diff (2068B)


      1 Description: Bookmarks support via dmenu and ~/.surf/bookmarks
      2 Ported from surf-bookmarks-20170722-723ff26.diff to current surf-webkit2.
      3 Ctrl+G (Go) and Ctrl+F (Find) prompts show bookmarks in dmenu.
      4 Ctrl+M adds current URL to ~/.surf/bookmarks (deduped, stripped of scheme).
      5 
      6 Requires: touch ~/.surf/bookmarks
      7 
      8 Apply:   patch -p1 < patches/surf-bookmarks.diff
      9 Unpatch: patch -R -p1 < patches/surf-bookmarks.diff
     10 
     11 diff --git a/config.def.h b/config.def.h
     12 --- a/config.def.h
     13 +++ b/config.def.h
     14 @@ -69,8 +69,8 @@
     15  #define SETPROP(r, s, p) { \
     16          .v = (const char *[]){ "/bin/sh", "-c", \
     17               "prop=\"$(printf '%b' \"$(xprop -id $1 "r" " \
     18               "| sed -e 's/^"r"(UTF8_STRING) = \"\\(.*\\)\"/\\1/' " \
     19 -             "      -e 's/\\\\\\(.\\)/\\1/g')\" " \
     20 -             "| dmenu -p '"p"' -w $1)\" " \
     21 +             "      -e 's/\\\\\\(.\\)/\\1/g' && cat ~/.surf/bookmarks)\" " \
     22 +             "| dmenu -l 10 -p '"p"' -w $1)\" " \
     23               "&& xprop -id $1 -f "s" 8u -set "s" \"$prop\"", \
     24               "surf-setprop", winid, NULL \
     25          } \
     26 @@ -103,6 +103,17 @@
     27          } \
     28  }
     29 
     30 +/* BM_ADD(readprop) */
     31 +#define BM_ADD(r) {\
     32 +        .v = (const char *[]){ "/bin/sh", "-c", \
     33 +             "(echo $(xprop -id $0 "r") | cut -d '\"' -f2 " \
     34 +             "| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.surf/bookmarks) " \
     35 +             "| awk '!seen[$0]++' > ~/.surf/bookmarks.tmp && " \
     36 +             "mv ~/.surf/bookmarks.tmp ~/.surf/bookmarks", \
     37 +             winid, NULL \
     38 +        } \
     39 +}
     40 +
     41  /* styles */
     42  /*
     43   * The iteration will stop at the first match, beginning at the beginning of
     44 @@ -135,6 +146,7 @@
     45  	{ MODKEY,                GDK_KEY_f,      spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
     46  	{ MODKEY,                GDK_KEY_slash,  spawn,      SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
     47 
     48 +	{ MODKEY,                GDK_KEY_m,      spawn,      BM_ADD("_SURF_URI") },
     49  	{ 0,                     GDK_KEY_Escape, stop,       { 0 } },
     50  	{ MODKEY,                GDK_KEY_c,      stop,       { 0 } },