first commit

This commit is contained in:
Maddie H 2022-02-25 16:51:45 +00:00
commit 66db59e82f
16 changed files with 3048 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.o
surf

10
FAQ.md Normal file
View File

@ -0,0 +1,10 @@
# Frequently Asked Questions
## Surf is starting up slowly. What might be causing this?
The first suspect for such behaviour is the plugin handling. Run surf on
the commandline and see if there are errors because of “nspluginwrapper”
or failed RPCs to them. If that is true, go to ~/.mozilla/plugins and
try removing stale links to plugins not on your system anymore. This
will stop surf from trying to load them.

57
LICENSE Normal file
View File

@ -0,0 +1,57 @@
MIT/X Consortium License
© 2009-2010 Enno Boland <tox@s01.de>
© 2009 Thomas Menari <spaceinvader@chaotika.org>
© 2009 Simon Rozet <simon@rozet.name>
© 2009 Andrew Antle <andrew.antle@gmail.com>
© 2010-2011 pancake <nopcode.org>
© 2011-2013 Anselm R Garbe <anselm@garbe.us>
© 2011-2012 Troels Henriksen <athas@sigkill.dk>
© 2011 Connor Lane Smith <cls@lubutu.com>
© 2012-2017 Christoph Lohmann <20h@r-36.net>
© 2013 Shayan Pooya <shayan@liveve.org>
© 2013 Jens Nyberg <jens.nyberg@gmail.com>
© 2013 Carlos J. Torres <vlaadbrain@gmail.com>
© 2013 Alexander Sedov <alex0player@gmail.com>
© 2013 Nick White <git@njw.me.uk>
© 2013 David Dufberg <david@dufberg.se>
© 2014-2021 Quentin Rameau <quinq@fifth.space>
© 2014-2016 Markus Teich <markus.teich@stusta.mhn.de>
© 2015 Jakukyo Friel <weakish@gmail.com>
© 2015 Ben Woolley <tautolog@gmail.com>
© 2015 Greg Reagle <greg.reagle@umbc.edu>
© 2015 GhostAV <ghostav@riseup.net>
© 2015-2017 Ivan Tham <pickfire@riseup.net>
© 2015 Alexander Huemer <alexander.huemer@xx.vu>
© 2015 Michael Stevens <mstevens@etla.org>
© 2015 Felix Janda <felix.janda@posteo.de>
© 2016 Charles Lehner <cel@celehner.com>
© 2016 Dmitry Bogatov <KAction@gnu.org>
© 2017 Hiltjo Posthuma <hiltjo@codemadness.org>
© 2017 ssd <ssd@mailless.org>
© 2017 Constantine Bytensky <kostya3@gmail.com>
© 2017 Eon S. Jeon <esjeon@hyunmu.am>
© 2017 Jochen Sprickerhof <git@jochen.sprickerhof.de>
© 2018 nzl <uruabi@gmail.com>
© 2018 Eddie Thieda <eddie.thieda@gmail.com>
© 2018 Leonardo Taccari <iamleot@gmail.com>
© 2019 efe <efe@efe.kim>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

76
Makefile Normal file
View File

@ -0,0 +1,76 @@
# surf - simple browser
# See LICENSE file for copyright and license details.
.POSIX:
include config.mk
SRC = surf.c
WSRC = webext-surf.c
OBJ = $(SRC:.c=.o)
WOBJ = $(WSRC:.c=.o)
WLIB = $(WSRC:.c=.so)
all: options surf $(WLIB)
options:
@echo surf build options:
@echo "CC = $(CC)"
@echo "CFLAGS = $(SURFCFLAGS) $(CFLAGS)"
@echo "WEBEXTCFLAGS = $(WEBEXTCFLAGS) $(CFLAGS)"
@echo "LDFLAGS = $(LDFLAGS)"
surf: $(OBJ)
$(CC) $(SURFLDFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
$(OBJ) $(WOBJ): config.h common.h config.mk
config.h:
cp config.def.h $@
$(OBJ): $(SRC)
$(CC) $(SURFCFLAGS) $(CFLAGS) -c $(SRC)
$(WLIB): $(WOBJ)
$(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $? $(WEBEXTLIBS)
$(WOBJ): $(WSRC)
$(CC) $(WEBEXTCFLAGS) $(CFLAGS) -c $(WSRC)
clean:
rm -f surf $(OBJ)
rm -f $(WLIB) $(WOBJ)
distclean: clean
rm -f config.h surf-$(VERSION).tar.gz
dist: distclean
mkdir -p surf-$(VERSION)
cp -R LICENSE Makefile config.mk config.def.h README \
surf-open.sh arg.h TODO.md surf.png \
surf.1 common.h $(SRC) $(WSRC) surf-$(VERSION)
tar -cf surf-$(VERSION).tar surf-$(VERSION)
gzip surf-$(VERSION).tar
rm -rf surf-$(VERSION)
install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f surf $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/surf
mkdir -p $(DESTDIR)$(LIBDIR)
cp -f $(WLIB) $(DESTDIR)$(LIBDIR)
for wlib in $(WLIB); do \
chmod 644 $(DESTDIR)$(LIBDIR)/$$wlib; \
done
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
sed "s/VERSION/$(VERSION)/g" < surf.1 > $(DESTDIR)$(MANPREFIX)/man1/surf.1
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/surf.1
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/surf
rm -f $(DESTDIR)$(MANPREFIX)/man1/surf.1
for wlib in $(WLIB); do \
rm -f $(DESTDIR)$(LIBDIR)/$$wlib; \
done
- rmdir $(DESTDIR)$(LIBDIR)
.PHONY: all options distclean clean dist install uninstall

40
README Normal file
View File

@ -0,0 +1,40 @@
surf - simple webkit-based browser
==================================
surf is a simple Web browser based on WebKit/GTK+.
Requirements
------------
In order to build surf you need GTK+ and Webkit/GTK+ header files.
In order to use the functionality of the url-bar, also install dmenu[0].
Installation
------------
Edit config.mk to match your local setup (surf is installed into
the /usr/local namespace by default).
Afterwards enter the following command to build and install surf (if
necessary as root):
make clean install
Running surf
------------
run
surf [URI]
See the manpage for further options.
Running surf in tabbed
----------------------
For running surf in tabbed[1] there is a script included in the distribution,
which is run like this:
surf-open.sh [URI]
Further invocations of the script will run surf with the specified URI in this
instance of tabbed.
[0] http://tools.suckless.org/dmenu
[1] http://tools.suckless.org/tabbed

1
README.md Normal file
View File

@ -0,0 +1 @@
# surf

10
TODO.md Normal file
View File

@ -0,0 +1,10 @@
# TODO
* suckless adblocking
* replace twitch() with proper gtk calls to make scrollbars reappear
* replace webkit with something sane
* add video player options
* play in plugin
* play in video player
* call command with URI (quvi + cclive)

48
arg.h Normal file
View File

@ -0,0 +1,48 @@
/*
* Copy me if you can.
* by 20h
*/
#ifndef ARG_H__
#define ARG_H__
extern char *argv0;
/* use main(int argc, char *argv[]) */
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
argv[0] && argv[0][0] == '-'\
&& argv[0][1];\
argc--, argv++) {\
char argc_;\
char **argv_;\
int brk_;\
if (argv[0][1] == '-' && argv[0][2] == '\0') {\
argv++;\
argc--;\
break;\
}\
for (brk_ = 0, argv[0]++, argv_ = argv;\
argv[0][0] && !brk_;\
argv[0]++) {\
if (argv_ != argv)\
break;\
argc_ = argv[0][0];\
switch (argc_)
#define ARGEND }\
}
#define ARGC() argc_
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
((x), abort(), (char *)0) :\
(brk_ = 1, (argv[0][1] != '\0')?\
(&argv[0][1]) :\
(argc--, argv++, argv[0])))
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
(char *)0 :\
(brk_ = 1, (argv[0][1] != '\0')?\
(&argv[0][1]) :\
(argc--, argv++, argv[0])))
#endif

1
common.h Normal file
View File

@ -0,0 +1 @@
#define MSGBUFSZ 8

194
config.def.h Normal file
View File

@ -0,0 +1,194 @@
/* modifier 0 means no modifier */
static int surfuseragent = 1; /* Append Surf version to default WebKit user agent */
static char *fulluseragent = ""; /* Or override the whole user agent string */
static char *scriptfile = "~/.surf/script.js";
static char *styledir = "~/.surf/styles/";
static char *certdir = "~/.surf/certificates/";
static char *cachedir = "~/.surf/cache/";
static char *cookiefile = "~/.surf/cookies.txt";
/* Webkit default features */
/* Highest priority value will be used.
* Default parameters are priority 0
* Per-uri parameters are priority 1
* Command parameters are priority 2
*/
static Parameter defconfig[ParameterLast] = {
/* parameter Arg value priority */
[AccessMicrophone] = { { .i = 0 }, },
[AccessWebcam] = { { .i = 0 }, },
[Certificate] = { { .i = 0 }, },
[CaretBrowsing] = { { .i = 0 }, },
[CookiePolicies] = { { .v = "@Aa" }, },
[DefaultCharset] = { { .v = "UTF-8" }, },
[DiskCache] = { { .i = 1 }, },
[DNSPrefetch] = { { .i = 0 }, },
[Ephemeral] = { { .i = 0 }, },
[FileURLsCrossAccess] = { { .i = 0 }, },
[FontSize] = { { .i = 12 }, },
[FrameFlattening] = { { .i = 0 }, },
[Geolocation] = { { .i = 0 }, },
[HideBackground] = { { .i = 0 }, },
[Inspector] = { { .i = 0 }, },
[Java] = { { .i = 1 }, },
[JavaScript] = { { .i = 1 }, },
[KioskMode] = { { .i = 0 }, },
[LoadImages] = { { .i = 1 }, },
[MediaManualPlay] = { { .i = 1 }, },
[PreferredLanguages] = { { .v = (char *[]){ NULL } }, },
[RunInFullscreen] = { { .i = 0 }, },
[ScrollBars] = { { .i = 1 }, },
[ShowIndicators] = { { .i = 1 }, },
[SiteQuirks] = { { .i = 1 }, },
[SmoothScrolling] = { { .i = 0 }, },
[SpellChecking] = { { .i = 0 }, },
[SpellLanguages] = { { .v = ((char *[]){ "en_US", NULL }) }, },
[StrictTLS] = { { .i = 1 }, },
[Style] = { { .i = 1 }, },
[WebGL] = { { .i = 0 }, },
[ZoomLevel] = { { .f = 1.0 }, },
};
static UriParameters uriparams[] = {
{ "(://|\\.)suckless\\.org(/|$)", {
[JavaScript] = { { .i = 0 }, 1 },
}, },
};
/* default window size: width, height */
static int winsize[] = { 800, 600 };
static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
WEBKIT_FIND_OPTIONS_WRAP_AROUND;
#define PROMPT_GO "Go:"
#define PROMPT_FIND "Find:"
/* SETPROP(readprop, setprop, prompt)*/
#define SETPROP(r, s, p) { \
.v = (const char *[]){ "/bin/sh", "-c", \
"prop=\"$(printf '%b' \"$(xprop -id $1 "r" " \
"| sed -e 's/^"r"(UTF8_STRING) = \"\\(.*\\)\"/\\1/' " \
" -e 's/\\\\\\(.\\)/\\1/g')\" " \
"| dmenu -p '"p"' -w $1)\" " \
"&& xprop -id $1 -f "s" 8u -set "s" \"$prop\"", \
"surf-setprop", winid, NULL \
} \
}
/* DOWNLOAD(URI, referer) */
#define DOWNLOAD(u, r) { \
.v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
"curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \
" -e \"$3\" \"$4\"; read", \
"surf-download", useragent, cookiefile, r, u, NULL \
} \
}
/* PLUMB(URI) */
/* This called when some URI which does not begin with "about:",
* "http://" or "https://" should be opened.
*/
#define PLUMB(u) {\
.v = (const char *[]){ "/bin/sh", "-c", \
"xdg-open \"$0\"", u, NULL \
} \
}
/* VIDEOPLAY(URI) */
#define VIDEOPLAY(u) {\
.v = (const char *[]){ "/bin/sh", "-c", \
"mpv --really-quiet \"$0\"", u, NULL \
} \
}
/* styles */
/*
* The iteration will stop at the first match, beginning at the beginning of
* the list.
*/
static SiteSpecific styles[] = {
/* regexp file in $styledir */
{ ".*", "default.css" },
};
/* certificates */
/*
* Provide custom certificate for urls
*/
static SiteSpecific certs[] = {
/* regexp file in $certdir */
{ "://suckless\\.org/", "suckless.org.crt" },
};
#define MODKEY GDK_CONTROL_MASK
/* hotkeys */
/*
* If you use anything else but MODKEY and GDK_SHIFT_MASK, don't forget to
* edit the CLEANMASK() macro.
*/
static Key keys[] = {
/* modifier keyval function arg */
{ 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) },
{ 0, GDK_KEY_Escape, stop, { 0 } },
{ MODKEY, GDK_KEY_c, stop, { 0 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
{ MODKEY, GDK_KEY_r, reload, { .i = 0 } },
{ MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
{ MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
/* vertical and horizontal scrolling, in viewport percentage */
{ MODKEY, GDK_KEY_j, scrollv, { .i = +10 } },
{ MODKEY, GDK_KEY_k, scrollv, { .i = -10 } },
{ MODKEY, GDK_KEY_space, scrollv, { .i = +50 } },
{ MODKEY, GDK_KEY_b, scrollv, { .i = -50 } },
{ MODKEY, GDK_KEY_i, scrollh, { .i = +10 } },
{ MODKEY, GDK_KEY_u, scrollh, { .i = -10 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
{ MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
{ MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
{ MODKEY, GDK_KEY_p, clipboard, { .i = 1 } },
{ MODKEY, GDK_KEY_y, clipboard, { .i = 0 } },
{ MODKEY, GDK_KEY_n, find, { .i = +1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
{ MODKEY, GDK_KEY_t, showcert, { 0 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
{ 0, GDK_KEY_F11, togglefullscreen, { 0 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_o, toggleinspector, { 0 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_c, toggle, { .i = CaretBrowsing } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_f, toggle, { .i = FrameFlattening } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_g, toggle, { .i = Geolocation } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_s, toggle, { .i = JavaScript } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_i, toggle, { .i = LoadImages } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_b, toggle, { .i = ScrollBars } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_t, toggle, { .i = StrictTLS } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } },
};
/* button definitions */
/* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */
static Button buttons[] = {
/* target event mask button function argument stop event */
{ OnLink, 0, 2, clicknewwindow, { .i = 0 }, 1 },
{ OnLink, MODKEY, 2, clicknewwindow, { .i = 1 }, 1 },
{ OnLink, MODKEY, 1, clicknewwindow, { .i = 1 }, 1 },
{ OnAny, 0, 8, clicknavigate, { .i = -1 }, 1 },
{ OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 },
{ OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 },
};

32
config.mk Normal file
View File

@ -0,0 +1,32 @@
# surf version
VERSION = 2.1
# Customize below to fit your system
# paths
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
LIBPREFIX = $(PREFIX)/lib
LIBDIR = $(LIBPREFIX)/surf
X11INC = `pkg-config --cflags x11`
X11LIB = `pkg-config --libs x11`
GTKINC = `pkg-config --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0`
GTKLIB = `pkg-config --libs gtk+-3.0 gcr-3 webkit2gtk-4.0`
WEBEXTINC = `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0 gio-2.0`
WEBEXTLIBS = `pkg-config --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0 gio-2.0`
# includes and libs
INCS = $(X11INC) $(GTKINC)
LIBS = $(X11LIB) $(GTKLIB) -lgthread-2.0
# flags
CPPFLAGS = -DVERSION=\"$(VERSION)\" -DGCR_API_SUBJECT_TO_CHANGE \
-DLIBPREFIX=\"$(LIBPREFIX)\" -DWEBEXTDIR=\"$(LIBDIR)\" \
-D_DEFAULT_SOURCE
SURFCFLAGS = -fPIC $(INCS) $(CPPFLAGS)
WEBEXTCFLAGS = -fPIC $(WEBEXTINC)
# compiler
#CC = c99

32
surf-open.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh
#
# See the LICENSE file for copyright and license details.
#
xidfile="$HOME/tmp/tabbed-surf.xid"
uri=""
if [ "$#" -gt 0 ];
then
uri="$1"
fi
runtabbed() {
tabbed -dn tabbed-surf -r 2 surf -e '' "$uri" >"$xidfile" \
2>/dev/null &
}
if [ ! -r "$xidfile" ];
then
runtabbed
else
xid=$(cat "$xidfile")
xprop -id "$xid" >/dev/null 2>&1
if [ $? -gt 0 ];
then
runtabbed
else
surf -e "$xid" "$uri" >/dev/null 2>&1 &
fi
fi

305
surf.1 Normal file
View File

@ -0,0 +1,305 @@
.TH SURF 1 surf\-VERSION
.SH NAME
surf \- simple webkit-based browser
.SH SYNOPSIS
.B surf
.RB [-bBdDfFgGiIkKmMnNpPsStTvwxX]
.RB [-a\ cookiepolicies]
.RB [-c\ cookiefile]
.RB [-C\ stylefile]
.RB [-e\ xid]
.RB [-r\ scriptfile]
.RB [-u\ useragent]
.RB [-z\ zoomlevel]
.RB [URI]
.SH DESCRIPTION
surf is a simple Web browser based on WebKit/GTK+. It is able
to display websites and follow links. It supports the XEmbed protocol
which makes it possible to embed it in another application. Furthermore,
one can point surf to another URI by setting its XProperties.
.SH OPTIONS
.TP
.B \-a cookiepolicies
Define the order of
.I cookie policies\fR.
The default is "@Aa" but could be
redefined in the
.IR config.h ,
with "A" meaning to
accept all cookies, "a" to deny all cookies and "@", which tells surf to
accept no third party cookies.
.TP
.B \-b
Disable Scrollbars.
.TP
.B \-B
Enable Scrollbars.
.TP
.B \-c cookiefile
Specify the
.I cookiefile
to use.
.TP
.B \-C stylefile
Specify the user
.IR stylefile .
This does disable the site-specific styles.
.TP
.B \-d
Disable the disk cache.
.TP
.B \-D
Enable the disk cache.
.TP
.B \-e xid
Reparents to window specified by
.IR xid .
.TP
.B \-f
Start surf in windowed mode (not fullscreen).
.TP
.B \-F
Start surf in fullscreen mode.
.TP
.B \-g
Disable giving the geolocation to websites.
.TP
.B \-G
Enable giving the geolocation to websites.
.TP
.B \-i
Disable Images.
.TP
.B \-I
Enable Images.
.TP
.B \-k
Disable kiosk mode (disable key strokes and right click).
.TP
.B \-K
Enable kiosk mode (disable key strokes and right click).
.TP
.B \-m
Disable application of user style sheets.
.TP
.B \-M
Enable application of user style sheets.
.TP
.B \-n
Disable the Web Inspector (Developer Tools).
.TP
.B \-N
Enable the Web Inspector (Developer Tools).
.TP
.B \-r scriptfile
Specify the user
.IR scriptfile .
.TP
.B \-s
Disable Javascript.
.TP
.B \-S
Enable Javascript.
.TP
.B \-t
Disable strict TLS check.
.TP
.B \-T
Enable strict TLS check.
.TP
.B \-u useragent
Specify the
.I useragent
which surf should use.
.TP
.B \-v
Prints version information to standard output, then exits.
.TP
.B \-w
Prints xid to standard output. This can be used to script the browser in for
example
.BR xdotool(1) .
.TP
.B -x
Disable custom certificates.
.TP
.B -X
Enable custom certificates.
.TP
.B \-z zoomlevel
Specify the
.I zoomlevel
which surf should use.
.SH USAGE
.B Escape
Stops loading current page or stops download.
.TP
.B Ctrl\-h
Walks back the history.
.TP
.B Ctrl\-l
Walks forward the history.
.TP
.B Ctrl\-k
Scrolls page upwards.
.TP
.B Ctrl\-j
Scrolls page downwards.
.TP
.B Ctrl\-b
Scroll up one whole page view.
.TP
.B Ctrl\-Space
Scroll down one whole page view.
.TP
.B Ctrl\-i
Scroll horizontally to the right.
.TP
.B Ctrl\-u
Scroll horizontally to the left.
.TP
.B Ctrl\-Shift\-k or Ctrl\-+
Zooms page in.
.TP
.B Ctrl\-Shift\-j or Ctrl\--
Zooms page out.
.TP
.B Ctrl\-Shift\-q
Resets Zoom.
.TP
.B Ctrl\-f and Ctrl\-/
Opens the search-bar.
.TP
.B Ctrl\-n
Go to next search result.
.TP
.B Ctrl\-Shift\-n
Go to previous search result.
.TP
.B Ctrl\-g
Opens the URL-bar (requires dmenu installed).
.TP
.B Ctrl\-p
Loads URI from primary selection.
.TP
.B Ctrl\-Shift\-p
Calls Printpage Dialog.
.TP
.B Ctrl\-r
Reloads the website.
.TP
.B Ctrl\-Shift\-r
Reloads the website without using the cache.
.TP
.B Ctrl\-y
Copies current URI to primary selection.
.TP
.B Ctrl\-t
Display the current TLS certificate in a popup window.
.TP
.B Ctrl\-Shift\-a
Toggle through the the
.I cookie policies\fR.
This will not reload the page.
.TP
.B Ctrl\-Shift\-b
Toggle scrollbars. This will reload the page.
.TP
.B Ctrl\-Shift\-c
Toggle caret browsing. This will reload the page.
.TP
.B Ctrl\-Shift\-i
Toggle auto-loading of images. This will reload the page.
.TP
.B Ctrl\-Shift\-m
Toggle if the
.I stylefile
file should be loaded. This will reload the page.
.TP
.B Ctrl\-Shift\-o
Open the Web Inspector (Developer Tools) window for the current page.
.TP
.B Ctrl\-Shift\-s
Toggle script execution. This will reload the page.
.TP
.B Ctrl\-Shift\-t
Toggle strict TLS check. This will reload the page.
.TP
.B F11
Toggle fullscreen mode.
.SH INDICATORS OF OPERATION
Surf is showing indicators of operation in front of the site title.
For all indicators, unless otherwise specified, a lower case letter means disabled and an upper case letter means enabled.
.TP
.B A
all cookies accepted
.TP
.B a
no cookies accepted
.TP
.B @
all except third-party cookies accepted
.TP
.B c C
caret browsing
.TP
.B g G
geolocation
.TP
.B d D
disk cache
.TP
.B i I
images
.TP
.B s S
scripts
.TP
.B m M
styles
.TP
.B f F
frame flattening
.TP
.B x X
custom certificates
.TP
.B t T
strict TLS
.SH INDICATORS OF WEB PAGE
The second part of the indicators specifies modes of the web page itself.
.SS First character: encryption
.TP
.B -
unencrypted
.TP
.B T
encrypted (TLS)
.TP
.B U
attempted encryption but failed
.SS Second character: proxying
.TP
.B -
no proxy
.TP
.B P
using proxy
.SH ENVIRONMENT
.B SURF_USERAGENT
If this variable is set upon startup, surf will use it as the
.I useragent
string.
.TP
.B http_proxy
If this variable is set and not empty upon startup, surf will use it as the http proxy.
.SH SIGNALS
Surf will reload the current page on
.BR SIGHUP .
.SH SEE ALSO
.BR dmenu(1),
.BR xprop(1),
.BR tabbed(1),
.BR xdotool(1)
.SH BUGS
Please report them!

2134
surf.c Normal file

File diff suppressed because it is too large Load Diff

BIN
surf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

106
webext-surf.c Normal file
View File

@ -0,0 +1,106 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <gio/gio.h>
#include <webkit2/webkit-web-extension.h>
#include <webkitdom/webkitdom.h>
#include <webkitdom/WebKitDOMDOMWindowUnstable.h>
#include "common.h"
#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
static WebKitWebExtension *webext;
static int sock;
static void
msgsurf(guint64 pageid, const char *s)
{
static char msg[MSGBUFSZ];
size_t sln = strlen(s);
int ret;
if ((ret = snprintf(msg, sizeof(msg), "%c%s", pageid, s))
>= sizeof(msg)) {
fprintf(stderr, "webext: msg: message too long: %d\n", ret);
return;
}
if (send(sock, msg, ret, 0) < 0)
fprintf(stderr, "webext: error sending: %s\n", msg+1);
}
static gboolean
readsock(GIOChannel *s, GIOCondition c, gpointer unused)
{
static char js[48], msg[MSGBUFSZ];
WebKitWebPage *page;
JSCContext *jsc;
GError *gerr = NULL;
gsize msgsz;
if (g_io_channel_read_chars(s, msg, sizeof(msg), &msgsz, &gerr) !=
G_IO_STATUS_NORMAL) {
if (gerr) {
fprintf(stderr, "webext: error reading socket: %s\n",
gerr->message);
g_error_free(gerr);
}
return TRUE;
}
if (msgsz < 2) {
fprintf(stderr, "webext: readsock: message too short: %d\n",
msgsz);
return TRUE;
}
if (!(page = webkit_web_extension_get_page(webext, msg[0])))
return TRUE;
jsc = webkit_frame_get_js_context(webkit_web_page_get_main_frame(page));
switch (msg[1]) {
case 'h':
if (msgsz != 3)
return TRUE;
snprintf(js, sizeof(js),
"window.scrollBy(window.innerWidth/100*%d,0);",
msg[2]);
jsc_context_evaluate(jsc, js, -1);
break;
case 'v':
if (msgsz != 3)
return TRUE;
snprintf(js, sizeof(js),
"window.scrollBy(0,window.innerHeight/100*%d);",
msg[2]);
jsc_context_evaluate(jsc, js, -1);
break;
}
return TRUE;
}
G_MODULE_EXPORT void
webkit_web_extension_initialize_with_user_data(WebKitWebExtension *e,
const GVariant *gv)
{
GIOChannel *gchansock;
webext = e;
g_variant_get(gv, "i", &sock);
gchansock = g_io_channel_unix_new(sock);
g_io_channel_set_encoding(gchansock, NULL, NULL);
g_io_channel_set_flags(gchansock, g_io_channel_get_flags(gchansock)
| G_IO_FLAG_NONBLOCK, NULL);
g_io_channel_set_close_on_unref(gchansock, TRUE);
g_io_add_watch(gchansock, G_IO_IN, readsock, NULL);
}