Surf browser external pipe throubleshoot

Hello.

I'm trying to mess around with surf and found the external pipe patch, which seems really powerful.

I did apply the patch and had some trouble building it, as C was complaining about type definitions in two base functions. Changing it to:

Code:
static void externalpipe_resource_done(GObject *source_object, GAsyncResult *s, gpointer user_data) {
    WebKitWebResource *r = WEBKIT_WEB_RESOURCE(source_object);
    Arg *arg = (Arg*)user_data;

...

static void externalpipe_js_done(GObject *source_object, GAsyncResult *s, gpointer user_data) {
    WebKitWebView *wv = WEBKIT_WEB_VIEW(source_object);
    Arg *arg = (Arg*)user_data;

and keeping the rest of the body fixed it, and surf compiled.

Later, I had issues with the surf_linkselect.sh awk since it was using GNU awk. I changed it to:

Code:
dump_links_with_titles() {
  awk '{
    input = $0;
    title = $0;
    link = "";

    # Extract title
    gsub("<[^>]*>", "", title);
    gsub(/[ ]+/, " ", title);
    gsub("&amp;", "&", title);
    gsub("&lt;", "<", title);
    gsub("&gt;", ">", title);
    if (title == "") title = "None";

    # Extract href attribute
    if (match($0, /<a [^>]*href=["]([^"]+)["]/)) {
      linkStart = RSTART;
      linkLength = RLENGTH;
      link = substr($0, linkStart, linkLength);

      # Cleanup link
      gsub(/.*href=["]/, "", link);
      gsub(/["].*/, "", link);
      gsub(/^[ \t]+|[ \t]+$/, "", link);
      gsub(" ", "%20", link);

      # Check if link starts with "//" and prepend "https:" if it does
      if (substr(link, 1, 2) == "//") {
        link = "https:" link;
      }
    }

    if (link != "") {
      print title ": " link;
    }
  }'
}

and so far so good.

Then we got:

Code:
static char *linkselect_curwin [] = { "/bin/sh", "-c",
    "surf_linkselect.sh $0 'Link' | xargs -r xprop -id $0 -f _SURF_GO 8s -set _SURF_GO",
    winid, NULL
};


And it works as it is intended: I press the shortcut to call linkselect_curwin, and it will map URLs in dmenu and set the one I choose in the _SURF_GO variable. But this does not seem to trigger the function at surf.c:

Code:
GdkFilterReturn
processx(GdkXEvent *e, GdkEvent *event, gpointer d)
{
    Client *c = (Client *)d;
    XPropertyEvent *ev;
    Arg a;

    if (((XEvent *)e)->type == PropertyNotify) {
        ev = &((XEvent *)e)->xproperty;
        if (ev->state == PropertyNewValue) {
            if (ev->atom == atoms[AtomFind]) {
                find(c, NULL);

                return GDK_FILTER_REMOVE;
            } else if (ev->atom == atoms[AtomGo]) {
                a.v = getatom(c, AtomGo);
                loaduri(c, &a);

                return GDK_FILTER_REMOVE;
            }
        }
    }
    return GDK_FILTER_CONTINUE;
}


I think this guy is triggered by the GO shortcut when we do C_g and enter a URL. But this is not being triggered by the externalpipe function, and also it does not trigger if I manually change _SURF_GO in the shell.

And that last part is only a shot.

I think now I need to be able to know if this is true, and so, I should be somehow able to debug surf.c or even make a debug patch that could send data to a log file maybe.

My point is to try to figure out the best way to fix that or know if someone uses externalpipe and wants to share knowledge.

Thanks!
 
Back
Top