You are not logged in.

#1 2013-08-06 22:27:11

defer
Member
From: Finland
Registered: 2013-06-25
Posts: 46
Website

Surf hacking - Share (or request) patches

Lets start surf hacking thread. Share your patches or suggest new ideas. Feel free to provide feedback or improvements.

surf-0.6-searchengine.patch
Patch to add homepage support and search engine integration. Can be configured with config.def.h. Detects if the entered url is valid url or search keyword. If it is search keyword surf directs it to search engine. Rules: If the url has dot and dont have spaces its url. If the url ends with slash its url. If the url is "localhost its url. Otherwise its search keyword.

diff -up surf-upstream/config.def.h surf/config.def.h
--- surf-upstream/config.def.h	2013-02-10 20:40:14.000000000 +0200
+++ surf/config.def.h	2013-08-06 21:04:17.150798111 +0300
@@ -16,6 +16,9 @@ static char *cafile         = "/etc/ssl/
 static char *strictssl      = FALSE; /* Refuse untrusted SSL connections */
 static int   indicator_thickness = 2;
 
+static char *searchengine	= "http://www.google.com/search?q=%s";
+static char *homepage		= "http://www.google.com/";
+
 /* Webkit default features */
 static Bool enablespatialbrowsing = TRUE;
 static Bool enableplugins = TRUE;
Only in surf/: config.h
diff -up surf-upstream/surf.c surf/surf.c
--- surf-upstream/surf.c	2013-02-10 20:40:14.000000000 +0200
+++ surf/surf.c	2013-08-07 00:53:13.778066638 +0300
@@ -626,9 +626,12 @@ loaduri(Client *c, const Arg *arg) {
 		rp = realpath(uri, NULL);
 		u = g_strdup_printf("file://%s", rp);
 		free(rp);
-	} else {
+	} else if ((g_strrstr(uri, ".") && !g_strrstr(uri, " ")) ||
+			uri[strlen(uri)-1] == '/' || g_strcmp0(uri, "localhost") >= 0) {
 		u = g_strrstr(uri, "://") ? g_strdup(uri)
 			: g_strdup_printf("http://%s", uri);
+	} else {
+		u = g_strdup_printf(searchengine, uri);
 	}
 
 	/* prevents endless loop */
@@ -1220,6 +1223,8 @@ main(int argc, char *argv[]) {
 	} ARGEND;
 	if(argc > 0)
 		arg.v = argv[0];
+	else
+		arg.v = homepage;
 
 	setup();
 	newclient();

Offline

#2 2013-08-06 22:37:24

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Surf hacking - Share (or request) patches

There are also some patches upstream: http://surf.suckless.org/patches/

Offline

#3 2013-08-07 10:55:56

totolotto
Member
From: Hungary
Registered: 2012-11-13
Posts: 114

Re: Surf hacking - Share (or request) patches

After trying many web browsers I ended up with Surf. In addition to some official patches I have applied the "default zoom" patch too becasue with 1920x1080 resolution on my TV I need 150% default zoom level. In surf.c

1. add this line in "static Client *newclient(void)" function:

webkit_web_view_set_zoom_level(c->view, 1.5);

2. change the default value for reset zoom level in "static void zoom function" from 1.0 to 1.5

	} else {
		/* reset */
		c->zoomed = FALSE;
		webkit_web_view_set_zoom_level(c->view, 1.5);
	}
}

I have only one issue with Surf: in some cases I cannot download files. For example links on h33t.com always work but links on kickasstorrents always fail with

" curl: (3) [globbing] error: bad range specification after pos 71"

Does anyone know the reason and how to fix it?

Offline

#4 2013-08-10 17:52:39

defer
Member
From: Finland
Registered: 2013-06-25
Posts: 46
Website

Re: Surf hacking - Share (or request) patches

I have few ideas / requests. Im not sure if some of them are already possible, i just started using surf.

1. Gui to select where to save downloads.
I think this should be easy by using zenity in #define DOWNLOAD(d, r)?. I will try this when i have time.

2. Borders between tabbed tabs.
Not so important anymore. Im already got used to them.

3. Image preview when opening file to upload.

4. Edit current url.
EDIT: modkey+g modkey+i
^This doesnt work after i added favorite urls modification?
EDIT: modkey+y modkey+g modkey+y works!

5. Suggest your favorite urls in dmenu when youre entering url.
EDIT: Create file ~/.surf/favorites.txt and add one url per line.
Edit config.def.h:

#define SETPROP(p, q) { \
        .v = (char *[]){ "/bin/sh", "-c", \
                "prop=\"`xprop -id $2 $0 | cut -d '\"' -f 2 | dmenu < ~/.surf/favorites.txt`\" &&" \
                "xprop -id $2 -f $1 8s -set $1 \"$prop\"", \
                p, q, winid, NULL \
        } \
}

Last edited by defer (2013-08-17 17:24:57)

Offline

#5 2013-08-10 17:56:48

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Surf hacking - Share (or request) patches

There are somewhat similar browsers, like dwb, which might already have what you want.
surf is pretty bare-bones, so might have to rely on external apps for much of the stuff you want to do.

Offline

#6 2013-08-10 18:40:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: Surf hacking - Share (or request) patches

A bit of relevant self promotion: here is the code to replace dmenu with interrobang for a url selector.  With customizable completion, it would be trivial to get 5 (and probably 4) above:

#interrobangrc excerpt:
bang surf    = echo %s
tab surf     = grep "%s%s" /path/to/favorites.urls

Where /path/to/favorites.urls is a list of urls.

EDIT: I should mention the `interrobang echo` in the linked-to code block would be changed to `interrobang surf` to use the above two lines.

Last edited by Trilby (2013-08-10 18:41:23)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2013-08-10 20:42:22

totolotto
Member
From: Hungary
Registered: 2012-11-13
Posts: 114

Re: Surf hacking - Share (or request) patches

defer wrote:

4. Edit current url.
You can yank url and load url from clipboard, but how to modify?

5. Suggest your favourite urls in dmenu when youre entering url.
Could be possible by setting file for favorite urls and modifying #define SETPROP(p, q)? I will try this when i have time.


4. MODKEY+g then MODKEY+i

5. Try the bookmark patch - I am happy with that.

Offline

#8 2013-08-17 18:06:13

defer
Member
From: Finland
Registered: 2013-06-25
Posts: 46
Website

Re: Surf hacking - Share (or request) patches

Trilby wrote:

A bit of relevant self promotion: here is the code to replace dmenu with interrobang for a url selector.  With customizable completion, it would be trivial to get 5 (and probably 4) above

What is this interrobang? Some kind of selector or url bar? Can i get screenshot?

----

How can i set surf to download files with wget to ~/downloads ? By default surf seems to use curl to download files.

It seems its in this part of config.def.h but i cant completely understand it. Why there is useragent and cookie parameters? Where is the download path defined?

/* DOWNLOAD(URI, referer) */
#define DOWNLOAD(d, r) { \
        .v = (char *[]){ "/bin/sh", "-c", \
                "st -e /bin/sh -c \"curl -J -O --user-agent '$1'" \
                " --referer '$2'" \
                " -b ~/.surf/cookies.txt -c ~/.surf/cookies.txt '$0';" \
                " sleep 5;\"", \
                d, useragent, r, NULL \
        } \
}

Offline

#9 2013-08-17 18:14:18

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Surf hacking - Share (or request) patches

defer wrote:
Trilby wrote:

A bit of relevant self promotion: here is the code to replace dmenu with interrobang for a url selector.  With customizable completion, it would be trivial to get 5 (and probably 4) above

What is this interrobang? Some kind of selector or url bar?

See https://bbs.archlinux.org/viewtopic.php?id=160182 and Trilby's signature.

Offline

#10 2013-08-17 18:27:17

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: Surf hacking - Share (or request) patches

Karol got it.  But in a very small nutshell, it's a launcher alternative to dmenu.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#11 2013-08-17 19:38:20

sekret
Member
Registered: 2013-07-22
Posts: 283

Re: Surf hacking - Share (or request) patches

defer wrote:

4. Edit current url.
EDIT: modkey+g modkey+i
^This doesnt work after i added favorite urls modification?
EDIT: modkey+y modkey+g modkey+y works!

This makes me wonder.. What about modkey+g tab?

Offline

#12 2013-08-17 20:52:21

defer
Member
From: Finland
Registered: 2013-06-25
Posts: 46
Website

Re: Surf hacking - Share (or request) patches

sekret wrote:

This makes me wonder.. What about modkey+g tab?

It spawns the first url from favorites with modkey-g modkey-i and modkey-g tab

Trilby wrote:

Karol got it.  But in a very small nutshell, it's a launcher alternative to dmenu.

Sorry but im not going to test it if i cant get screenshot first big_smile

Last edited by defer (2013-08-17 20:56:24)

Offline

#13 2013-08-17 21:41:55

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Surf hacking - Share (or request) patches

You know you don't have to test it; Trilby merely suggested it in case it might fit your needs better. If you're not wanting to test for yourself, stick to your own solutions...


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#14 2013-08-17 22:10:07

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: Surf hacking - Share (or request) patches

My post wasn't directed specifically at you defer, it was for the thread as idea for surf hacking.  If you want a screenshot before you try it, I'm pretty sure you wouldn't like it wink


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#15 2013-08-18 07:05:57

totolotto
Member
From: Hungary
Registered: 2012-11-13
Posts: 114

Re: Surf hacking - Share (or request) patches

How can i set surf to download files with wget to ~/downloads ? By default surf seems to use curl to download files.

I did not try wget but with curl to set the default location:

	/* DOWNLOAD(URI, referer) */
	#define DOWNLOAD(d, r) { \
		.v = (char *[]){ "/bin/sh", "-c", \
			"urxvtc -e /bin/sh -c \"cd /home/<username>/Downloads && curl -J -O --user-agent '$1'" \
			" --referer '$2'" \
			" -b ~/.surf/cookies.txt -c ~/.surf/cookies.txt '$0';" \
			" sleep 5;\"", \
			d, useragent, r, NULL \
		} \
	}

Offline

#16 2013-08-20 01:03:53

defer
Member
From: Finland
Registered: 2013-06-25
Posts: 46
Website

Re: Surf hacking - Share (or request) patches

It would be nice if tabbed had equal sized tabs. I cant figure out how to implement it. hmm

totolotto wrote:

I did not try wget but with curl to set the default location

Thanks!

Last edited by defer (2013-08-20 01:13:14)

Offline

#17 2013-08-20 12:10:58

marttt
Member
Registered: 2013-05-21
Posts: 22

Re: Surf hacking - Share (or request) patches

Something similar to LeechBlock or Chrome Nanny for surf would be great. (Being minimalist and undistracted definitely sucks less. smile)

Maybe this script could be directly integrated to surf: https://github.com/leftnode/get-shit-done

BTW, thanks, defer, for starting this thread!

Offline

#18 2013-08-20 12:43:59

totolotto
Member
From: Hungary
Registered: 2012-11-13
Posts: 114

Re: Surf hacking - Share (or request) patches

What is the difference between LeechBlock and blacklisting sites with privoxy?

Offline

#19 2013-08-22 12:27:44

marttt
Member
Registered: 2013-05-21
Posts: 22

Re: Surf hacking - Share (or request) patches

totolotto wrote:

What is the difference between LeechBlock and blacklisting sites with privoxy?

I've no experience with privoxy (but I did read this -- interesting!). I found LeechBlock very effective because I could also block access to its settings, so I was not able to "hack myself out" of the site access restrictions. With privoxy -- I assume -- modifying settings is just a matter of becoming root?

Offline

#20 2013-12-10 03:19:01

dluco
Member
Registered: 2013-08-30
Posts: 22

Re: Surf hacking - Share (or request) patches

Anyone else getting a "cISV |"  before the title of every url?
An example is: "cISV | ArchWiki"
It happens on both a 64- and 32-bit box.

Offline

#21 2013-12-10 05:09:38

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: Surf hacking - Share (or request) patches

@ dluco, it shows the status for different options such as images, scripts etc.

Upper case denotes an enabled option, and lower case denotes a disabled option.

Take a look here:

http://lists.suckless.org/dev/1302/14528.html

Last edited by x33a (2013-12-10 05:13:01)

Offline

#22 2013-12-10 05:21:33

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: Surf hacking - Share (or request) patches

marttt wrote:
totolotto wrote:

What is the difference between LeechBlock and blacklisting sites with privoxy?

I've no experience with privoxy (but I did read this -- interesting!). I found LeechBlock very effective because I could also block access to its settings, so I was not able to "hack myself out" of the site access restrictions. With privoxy -- I assume -- modifying settings is just a matter of becoming root?

As long as you are root nothing will help you. Installing an unrestrictet browser is no challenge. Use privoxy, force http(s) traffic through it and use pam_time to block root access for some hours.

Last edited by progandy (2013-12-10 05:28:49)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#23 2014-04-07 01:56:53

henriqueleng
Member
Registered: 2014-02-18
Posts: 77

Re: Surf hacking - Share (or request) patches

Hi, does someone here setted DuckDuckGo as search engine and can tell me how did it! The official site didn't tell how to do it, and i didn't found anything on internet. Appear that just we use surf, haha.


Emacs - tmux - Cmus - Mutt - Lynx/w3m - ....

Offline

#24 2014-04-07 02:27:30

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Surf hacking - Share (or request) patches

henriqueleng wrote:

Hi, does someone here setted DuckDuckGo as search engine and can tell me how did it! The official site didn't tell how to do it, and i didn't found anything on internet. Appear that just we use surf, haha.

https://bbs.archlinux.org/viewtopic.php … 2#p1308782 provides an example how to add google search. Have you treid to do something similar with DDG?

I've found https://bbs.archlinux.org/viewtopic.php?pid=1192047 and http://surf.suckless.org/patches/searchengines

Offline

#25 2016-03-02 23:44:49

Seninha
Member
From: Brasília - Brasil
Registered: 2012-04-05
Posts: 14

Re: Surf hacking - Share (or request) patches

Is there a patch that make me able to use commands without a modkey (just a single key, e.g. `j` instead of `MOD+j` to scroll down) and when I type this key into a textbox just its corresponding character be inserted and its corresponding command be not executed; typing out of a textbox would do the regular behaviour?

Offline

Board footer

Powered by FluxBB