You are not logged in.

#1 2012-11-12 21:24:33

jemofthewest
Member
Registered: 2012-02-27
Posts: 37

[solved] surf and DuckDuckGo

Hey all.  Newbie question here.

I'm an intermediate Linux user and programmer, and am looking to venture a little bit further down the rabbit hole of hacking.  I've installed dwm and am loving it, and currently use uzbl but the idea of surf fascinates me.

One feature that I loved about uzbl is using ddg to use duck duck go.  If surf would have this, I would have no reason to go back.  I'm trying to make sense of the source code for surf, and I get where keybinds go and in general where functions go but I have no idea where to start for this.

So I guess my first question is, has someone else done this already and I'm not able to find it via google?

And my second question if thats no is where would I begin to learn hacking this together?  Would it be a function in surf.c, or would I write it in config.h?  If this is too n00bish, I can just spend more time struggling through it...

Any tips would be appreciated, thanks!

Last edited by jemofthewest (2012-11-12 22:48:41)

Offline

#2 2012-11-12 21:27:22

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,050
Website

Re: [solved] surf and DuckDuckGo

Having tinkered with dwm and mimicked their approach in a number of my own apps, I can say that if you do write your own function it could go just as well in config.h or surf.c.

The only caveat is that if you put it in surf.c (which I personally would favor to keep things orderly) then you'd need to be sure to add the function prototype at the top of surf.c before the config.h include.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#3 2012-11-12 22:21:26

jemofthewest
Member
Registered: 2012-02-27
Posts: 37

Re: [solved] surf and DuckDuckGo

So let me ask a more specific question, now that I've done more digging...

It seems that surf calls dmenu, routes what you type (the URI) back into a variable and uses xprop to set _SURF_URI to what you typed.  Is that correct?  I've tried using xprop to set this manually to no avail, I keep getting

xprop: error: Invalid window id format: _SURF_URI.

though I do know the property exists.  I'm guessing I just don't know how to use xprop... if my understanding of this is correct, I think I know how to proceed but if I'm way off base let me know...  Thanks a lot...

Offline

#4 2012-11-12 22:35:57

jemofthewest
Member
Registered: 2012-02-27
Posts: 37

Re: [solved] surf and DuckDuckGo

Ok nvm I've figured it out...

xprop -format _SURF_GO 8s -set _SURF_GO "www.google.com"

takes surf to google.com, I'll post the function when I finish it for other people interested...  AFAIK there is no forum for surf hacking?  Just dwm and dmenu?  Thanks for the help...

Offline

#5 2012-11-12 22:51:50

jemofthewest
Member
Registered: 2012-02-27
Posts: 37

Re: [solved] surf and DuckDuckGo

#define DDG(p, q)     { .v = (char *[]){ "/bin/sh", "-c", \
	"prop=\"`xprop -id $2 $0 | cut -d '\"' -f 2 | dmenu -p ddg`\" &&" \
	"xprop -id $2 -f $1 8s -set $1 \"https://duckduckgo.com/?q=$prop\"", \
	p, q, winid, NULL } }

I put this in config.h right below the SETPROP function (since its pretty much just copied and pasted) and bound it to ^d.  Thanks for the pointer to get me started, that was the hardest part...

Offline

Board footer

Powered by FluxBB