Add code
parent
6be9e18c40
commit
ba57336132
|
@ -0,0 +1,3 @@
|
|||
*.o
|
||||
surf
|
||||
libsurf-webext.so
|
|
@ -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.
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
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-2017 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 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>
|
||||
|
||||
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.
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
# surf - simple browser
|
||||
# See LICENSE file for copyright and license details.
|
||||
.POSIX:
|
||||
|
||||
include config.mk
|
||||
|
||||
SRC = surf.c
|
||||
CSRC = common.c
|
||||
WEBEXTSRC = libsurf-webext.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
COBJ = $(CSRC:.c=.o)
|
||||
WEBEXTOBJ = $(WEBEXTSRC:.c=.o)
|
||||
|
||||
all: options libsurf-webext.so surf
|
||||
|
||||
options:
|
||||
@echo surf build options:
|
||||
@echo "CC = $(CC)"
|
||||
@echo "CFLAGS = $(SURFCFLAGS) $(CFLAGS)"
|
||||
@echo "WEBEXTCFLAGS = $(WEBEXTCFLAGS) $(CFLAGS)"
|
||||
@echo "LDFLAGS = $(LDFLAGS)"
|
||||
|
||||
.c.o:
|
||||
$(CC) $(SURFCFLAGS) $(CFLAGS) -c $<
|
||||
|
||||
config.h:
|
||||
cp config.def.h $@
|
||||
|
||||
$(OBJ): config.h common.h config.mk
|
||||
$(COBJ): config.h common.h config.mk
|
||||
$(WEBEXTOBJ): config.h common.h config.mk
|
||||
|
||||
$(WEBEXTOBJ): $(WEBEXTSRC)
|
||||
$(CC) $(WEBEXTCFLAGS) $(CFLAGS) -c $(WEBEXTSRC)
|
||||
|
||||
libsurf-webext.so: $(WEBEXTOBJ) $(COBJ)
|
||||
$(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ \
|
||||
$(WEBEXTOBJ) $(COBJ) $(WEBEXTLIBS)
|
||||
|
||||
surf: $(OBJ) $(COBJ)
|
||||
$(CC) $(SURFLDFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(COBJ) $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -f surf $(OBJ) $(COBJ)
|
||||
rm -f libsurf-webext.so $(WEBEXTOBJ)
|
||||
|
||||
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 $(SRC) $(WEBEXTSRC) 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 libsurf-webext.so $(DESTDIR)$(LIBDIR)
|
||||
chmod 644 $(DESTDIR)$(LIBDIR)/libsurf-webext.so
|
||||
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
|
||||
rm -f $(DESTDIR)$(LIBDIR)/libsurf-webext.so
|
||||
- rmdir $(DESTDIR)$(LIBDIR)
|
||||
|
||||
.SUFFIXES: .so .o .c
|
||||
.PHONY: all options clean-dist clean dist install uninstall
|
|
@ -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
|
||||
|
|
@ -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)
|
||||
|
|
@ -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
|
|
@ -0,0 +1,15 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void
|
||||
die(const char *errstr, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, errstr);
|
||||
vfprintf(stderr, errstr, ap);
|
||||
va_end(ap);
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
/* 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";
|
||||
static char *searchurl = "duckduckgo.com/?q=%s";
|
||||
static char *historyfile = "~/.surf/history.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 */
|
||||
[AcceleratedCanvas] = { { .i = 1 }, },
|
||||
[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 }, },
|
||||
[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 }, },
|
||||
[Plugins] = { { .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 },
|
||||
[Plugins] = { { .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 $2 " \
|
||||
"| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\" && cat ~/.surf/bookmarks)\" " \
|
||||
"| dmenu -l 10 -p \"$4\" -w $1)\" && " \
|
||||
"xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
|
||||
"surf-setprop", winid, r, s, p, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SEARCH() { \
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"xprop -id $1 -f $2 8s -set $2 \"" \
|
||||
"$(dmenu -p Search: -w $1 < /dev/null)\"", \
|
||||
"surf-search", winid, "_SURF_SEARCH", 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 \
|
||||
} \
|
||||
}
|
||||
|
||||
/* BM_ADD(readprop) */
|
||||
#define BM_ADD(r) {\
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \
|
||||
"| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.surf/bookmarks) " \
|
||||
"| awk '!seen[$0]++' > ~/.surf/bookmarks.tmp && " \
|
||||
"mv ~/.surf/bookmarks.tmp ~/.surf/bookmarks", \
|
||||
winid, r, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SETURI(p) { .v = (char *[]){ "/bin/sh", "-c", \
|
||||
"prop=\"`surf_history_dmenu.sh`\" &&" \
|
||||
"xprop -id $1 -f $0 8s -set $0 \"$prop\"", \
|
||||
p, winid, 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) },
|
||||
{ MODKEY, GDK_KEY_m, spawn, BM_ADD("_SURF_URI") },
|
||||
{ MODKEY, GDK_KEY_s, spawn, SEARCH() },
|
||||
|
||||
{ 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_v, toggle, { .i = Plugins } },
|
||||
{ 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 } },
|
||||
{ MODKEY , GDK_KEY_Return, spawn, SETURI("_SURF_GO") },
|
||||
};
|
||||
|
||||
/* 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 },
|
||||
};
|
|
@ -0,0 +1,225 @@
|
|||
/* 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";
|
||||
static char *searchurl = "https://www.startpage.com/do/dsearch?query=%s";
|
||||
static char *historyfile = "~/.surf/history.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 */
|
||||
[AcceleratedCanvas] = { { .i = 1 }, },
|
||||
[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 }, },
|
||||
[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 }, },
|
||||
[Plugins] = { { .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 },
|
||||
[Plugins] = { { .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 $2 " \
|
||||
"| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\" && cat ~/.surf/bookmarks)\" " \
|
||||
"| dmenu -l 10 -p \"$4\" -w $1)\" && " \
|
||||
"xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
|
||||
"surf-setprop", winid, r, s, p, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SEARCH() { \
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"xprop -id $1 -f $2 8s -set $2 \"" \
|
||||
"$(dmenu -p Search: -w $1 < /dev/null)\"", \
|
||||
"surf-search", winid, "_SURF_SEARCH", 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 \
|
||||
} \
|
||||
}
|
||||
|
||||
/* BM_ADD(readprop) */
|
||||
#define BM_ADD(r) {\
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \
|
||||
"| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.surf/bookmarks) " \
|
||||
"| awk '!seen[$0]++' > ~/.surf/bookmarks.tmp && " \
|
||||
"mv ~/.surf/bookmarks.tmp ~/.surf/bookmarks", \
|
||||
winid, r, NULL \
|
||||
} \
|
||||
}
|
||||
|
||||
#define SETURI(p) { .v = (char *[]){ "/bin/sh", "-c", \
|
||||
"prop=\"`~/bin/surf_history_dmenu.sh`\" &&" \
|
||||
"xprop -id $1 -f $0 8s -set $0 \"$prop\"", \
|
||||
p, winid, 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) },
|
||||
{ MODKEY, GDK_KEY_m, spawn, BM_ADD("_SURF_URI") },
|
||||
{ MODKEY, GDK_KEY_s, spawn, SEARCH() },
|
||||
|
||||
{ 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_v, toggle, { .i = Plugins } },
|
||||
{ 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 } },
|
||||
{ MODKEY , GDK_KEY_Return, spawn, SETURI("_SURF_GO") },
|
||||
};
|
||||
|
||||
/* 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 },
|
||||
};
|
|
@ -0,0 +1,31 @@
|
|||
# surf version
|
||||
VERSION = 2.0
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
# paths
|
||||
PREFIX = /usr
|
||||
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`
|
||||
WEBEXTLIBS = `pkg-config --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0`
|
||||
|
||||
# includes and libs
|
||||
INCS = $(X11INC) $(GTKINC)
|
||||
LIBS = $(X11LIB) $(GTKLIB) -lgthread-2.0
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -DVERSION=\"$(VERSION)\" -DWEBEXTDIR=\"$(LIBDIR)\" \
|
||||
-D_DEFAULT_SOURCE -DGCR_API_SUBJECT_TO_CHANGE
|
||||
SURFCFLAGS = $(INCS) $(CPPFLAGS) -fPIC
|
||||
WEBEXTCFLAGS = -fPIC $(WEBEXTINC)
|
||||
|
||||
# compiler
|
||||
#CC = c99
|
|
@ -0,0 +1,128 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.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]))
|
||||
|
||||
typedef struct Page {
|
||||
guint64 id;
|
||||
WebKitWebPage *webpage;
|
||||
struct Page *next;
|
||||
} Page;
|
||||
|
||||
static int pipein, pipeout;
|
||||
static Page *pages;
|
||||
|
||||
Page *
|
||||
newpage(WebKitWebPage *page)
|
||||
{
|
||||
Page *p;
|
||||
|
||||
if (!(p = calloc(1, sizeof(Page))))
|
||||
die("Cannot malloc!\n");
|
||||
|
||||
p->next = pages;
|
||||
pages = p;
|
||||
|
||||
p->id = webkit_web_page_get_id(page);
|
||||
p->webpage = page;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static void
|
||||
msgsurf(Page *p, const char *s)
|
||||
{
|
||||
static char msg[MSGBUFSZ];
|
||||
size_t sln = strlen(s);
|
||||
int ret;
|
||||
|
||||
if ((ret = snprintf(msg, sizeof(msg), "%c%c%s",
|
||||
2 + sln, p ? p->id : 0, s))
|
||||
>= sizeof(msg)) {
|
||||
fprintf(stderr, "webext: message too long: %d\n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pipeout && write(pipeout, msg, sizeof(msg)) < 0)
|
||||
fprintf(stderr, "webext: error sending: %.*s\n", ret-2, msg+2);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
readpipe(GIOChannel *s, GIOCondition c, gpointer unused)
|
||||
{
|
||||
static char msg[MSGBUFSZ], msgsz;
|
||||
WebKitDOMDOMWindow *view;
|
||||
GError *gerr = NULL;
|
||||
glong wh, ww;
|
||||
Page *p;
|
||||
|
||||
if (g_io_channel_read_chars(s, msg, LENGTH(msg), NULL, &gerr) !=
|
||||
G_IO_STATUS_NORMAL) {
|
||||
fprintf(stderr, "webext: error reading pipe: %s\n",
|
||||
gerr->message);
|
||||
g_error_free(gerr);
|
||||
return TRUE;
|
||||
}
|
||||
if ((msgsz = msg[0]) < 3) {
|
||||
fprintf(stderr, "webext: message too short: %d\n", msgsz);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (p = pages; p; p = p->next) {
|
||||
if (p->id == msg[1])
|
||||
break;
|
||||
}
|
||||
if (!p || !(view = webkit_dom_document_get_default_view(
|
||||
webkit_web_page_get_dom_document(p->webpage))))
|
||||
return TRUE;
|
||||
|
||||
switch (msg[2]) {
|
||||
case 'h':
|
||||
if (msgsz != 4)
|
||||
return TRUE;
|
||||
ww = webkit_dom_dom_window_get_inner_width(view);
|
||||
webkit_dom_dom_window_scroll_by(view,
|
||||
(ww / 100) * msg[3], 0);
|
||||
break;
|
||||
case 'v':
|
||||
if (msgsz != 4)
|
||||
return TRUE;
|
||||
wh = webkit_dom_dom_window_get_inner_height(view);
|
||||
webkit_dom_dom_window_scroll_by(view,
|
||||
0, (wh / 100) * msg[3]);
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
webpagecreated(WebKitWebExtension *e, WebKitWebPage *wp, gpointer unused)
|
||||
{
|
||||
Page *p = newpage(wp);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
webkit_web_extension_initialize_with_user_data(WebKitWebExtension *e, GVariant *gv)
|
||||
{
|
||||
GIOChannel *gchanpipe;
|
||||
|
||||
g_signal_connect(e, "page-created", G_CALLBACK(webpagecreated), NULL);
|
||||
|
||||
g_variant_get(gv, "(ii)", &pipein, &pipeout);
|
||||
msgsurf(NULL, "i");
|
||||
|
||||
gchanpipe = g_io_channel_unix_new(pipein);
|
||||
g_io_channel_set_encoding(gchanpipe, NULL, NULL);
|
||||
g_io_channel_set_close_on_unref(gchanpipe, TRUE);
|
||||
g_io_add_watch(gchanpipe, G_IO_IN, readpipe, NULL);
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
diff --git a/config.def.h b/config.def.h
|
||||
index 2e735bf..43ad9ab 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -69,8 +69,9 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
|
||||
#define SETPROP(r, s, p) { \
|
||||
.v = (const char *[]){ "/bin/sh", "-c", \
|
||||
"prop=\"$(printf '%b' \"$(xprop -id $1 $2 " \
|
||||
- "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\")\" " \
|
||||
- "| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
|
||||
+ "| sed \"s/^$2(STRING) = //;s/^\\\"\\(.*\\)\\\"$/\\1/\" && cat ~/.surf/bookmarks)\" " \
|
||||
+ "| dmenu -l 10 -p \"$4\" -w $1)\" && " \
|
||||
+ "xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
|
||||
"surf-setprop", winid, r, s, p, NULL \
|
||||
} \
|
||||
}
|
||||
@@ -101,6 +102,17 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
|
||||
} \
|
||||
}
|
||||
|
||||
+/* BM_ADD(readprop) */
|
||||
+#define BM_ADD(r) {\
|
||||
+ .v = (const char *[]){ "/bin/sh", "-c", \
|
||||
+ "(echo $(xprop -id $0 $1) | cut -d '\"' -f2 " \
|
||||
+ "| sed 's/.*https*:\\/\\/\\(www\\.\\)\\?//' && cat ~/.surf/bookmarks) " \
|
||||
+ "| awk '!seen[$0]++' > ~/.surf/bookmarks.tmp && " \
|
||||
+ "mv ~/.surf/bookmarks.tmp ~/.surf/bookmarks", \
|
||||
+ winid, r, NULL \
|
||||
+ } \
|
||||
+}
|
||||
+
|
||||
/* styles */
|
||||
/*
|
||||
* The iteration will stop at the first match, beginning at the beginning of
|
||||
@@ -132,6 +144,7 @@ static Key keys[] = {
|
||||
{ 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) },
|
||||
+ { MODKEY, GDK_KEY_m, spawn, BM_ADD("_SURF_URI") },
|
||||
|
||||
{ 0, GDK_KEY_Escape, stop, { 0 } },
|
||||
{ MODKEY, GDK_KEY_c, stop, { 0 } },
|
|
@ -0,0 +1,107 @@
|
|||
diff -up surf-2.0/config.def.h surf-2.0-history/config.def.h
|
||||
--- surf-2.0/config.def.h 2017-11-26 14:29:37.963786915 +0100
|
||||
+++ surf-2.0-history/config.def.h 2017-11-26 19:48:31.300096237 +0100
|
||||
@@ -6,6 +6,7 @@ static char *styledir = "~/.surf/s
|
||||
static char *certdir = "~/.surf/certificates/";
|
||||
static char *cachedir = "~/.surf/cache/";
|
||||
static char *cookiefile = "~/.surf/cookies.txt";
|
||||
+static char *historyfile = "~/.surf/history.txt";
|
||||
|
||||
/* Webkit default features */
|
||||
/* Highest priority value will be used.
|
||||
@@ -101,6 +102,11 @@ static WebKitFindOptions findopts = WEBK
|
||||
} \
|
||||
}
|
||||
|
||||
+#define SETURI(p) { .v = (char *[]){ "/bin/sh", "-c", \
|
||||
+"prop=\"`surf_history_dmenu.sh`\" &&" \
|
||||
+"xprop -id $1 -f $0 8s -set $0 \"$prop\"", \
|
||||
+p, winid, NULL } }
|
||||
+
|
||||
/* styles */
|
||||
/*
|
||||
* The iteration will stop at the first match, beginning at the beginning of
|
||||
@@ -181,6 +187,7 @@ static Key keys[] = {
|
||||
{ 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 } },
|
||||
+ { MODKEY , GDK_KEY_Return, spawn, SETURI("_SURF_GO") },
|
||||
};
|
||||
|
||||
/* button definitions */
|
||||
Only in surf-2.0-history/: config.h
|
||||
Only in surf-2.0: .git
|
||||
Only in surf-2.0-history/: surf
|
||||
diff -up surf-2.0/surf.c surf-2.0-history/surf.c
|
||||
--- surf-2.0/surf.c 2017-11-26 14:29:37.963786915 +0100
|
||||
+++ surf-2.0-history/surf.c 2017-11-26 14:20:36.757100476 +0100
|
||||
@@ -171,6 +171,7 @@ static void newwindow(Client *c, const A
|
||||
static void spawn(Client *c, const Arg *a);
|
||||
static void destroyclient(Client *c);
|
||||
static void cleanup(void);
|
||||
+static void updatehistory(const char *u, const char *t);
|
||||
|
||||
/* GTK/WebKit */
|
||||
static WebKitWebView *newview(Client *c, WebKitWebView *rv);
|
||||
@@ -336,10 +337,11 @@ setup(void)
|
||||
curconfig = defconfig;
|
||||
|
||||
/* dirs and files */
|
||||
- cookiefile = buildfile(cookiefile);
|
||||
- scriptfile = buildfile(scriptfile);
|
||||
- cachedir = buildpath(cachedir);
|
||||
- certdir = buildpath(certdir);
|
||||
+ cookiefile = buildfile(cookiefile);
|
||||
+ historyfile = buildfile(historyfile);
|
||||
+ scriptfile = buildfile(scriptfile);
|
||||
+ cachedir = buildpath(cachedir);
|
||||
+ certdir = buildpath(certdir);
|
||||
|
||||
gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy));
|
||||
|
||||
@@ -1042,12 +1044,28 @@ cleanup(void)
|
||||
while (clients)
|
||||
destroyclient(clients);
|
||||
g_free(cookiefile);
|
||||
+ g_free(historyfile);
|
||||
g_free(scriptfile);
|
||||
g_free(stylefile);
|
||||
g_free(cachedir);
|
||||
XCloseDisplay(dpy);
|
||||
}
|
||||
|
||||
+void
|
||||
+updatehistory(const char *u, const char *t)
|
||||
+{
|
||||
+ FILE *f;
|
||||
+ f = fopen(historyfile, "a+");
|
||||
+
|
||||
+ char b[20];
|
||||
+ time_t now = time (0);
|
||||
+ strftime (b, 20, "%Y-%m-%d %H:%M:%S", localtime (&now));
|
||||
+ fputs(b, f);
|
||||
+
|
||||
+ fprintf(f, " %s %s\n", u, t);
|
||||
+ fclose(f);
|
||||
+}
|
||||
+
|
||||
WebKitWebView *
|
||||
newview(Client *c, WebKitWebView *rv)
|
||||
{
|
||||
@@ -1417,6 +1435,7 @@ loadfailedtls(WebKitWebView *v, gchar *u
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+
|
||||
void
|
||||
loadchanged(WebKitWebView *v, WebKitLoadEvent e, Client *c)
|
||||
{
|
||||
@@ -1445,6 +1464,7 @@ loadchanged(WebKitWebView *v, WebKitLoad
|
||||
break;
|
||||
case WEBKIT_LOAD_FINISHED:
|
||||
seturiparameters(c, uri, loadfinished);
|
||||
+ updatehistory(uri, c->title);
|
||||
/* Disabled until we write some WebKitWebExtension for
|
||||
* manipulating the DOM directly.
|
||||
evalscript(c, "document.documentElement.style.overflow = '%s'",
|
||||
Only in surf-2.0-history/: surf.o
|
|
@ -0,0 +1,107 @@
|
|||
From c5ca896c5ba969b90f1e098d117c205a9b71d0db Mon Sep 17 00:00:00 2001
|
||||
From: Bryon Meinka <bryon.meinka@gmail.com>
|
||||
Date: Sat, 11 May 2019 00:52:29 -0400
|
||||
Subject: [PATCH] Web Search
|
||||
|
||||
---
|
||||
config.def.h | 10 ++++++++++
|
||||
surf.c | 20 +++++++++++++++++++-
|
||||
2 files changed, 29 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 34265f6..69657bf 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -6,6 +6,7 @@ static char *styledir = "~/.surf/styles/";
|
||||
static char *certdir = "~/.surf/certificates/";
|
||||
static char *cachedir = "~/.surf/cache/";
|
||||
static char *cookiefile = "~/.surf/cookies.txt";
|
||||
+static char *searchurl = "duckduckgo.com/?q=%s";
|
||||
|
||||
/* Webkit default features */
|
||||
/* Highest priority value will be used.
|
||||
@@ -76,6 +77,14 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
|
||||
} \
|
||||
}
|
||||
|
||||
+#define SEARCH() { \
|
||||
+ .v = (const char *[]){ "/bin/sh", "-c", \
|
||||
+ "xprop -id $1 -f $2 8s -set $2 \"" \
|
||||
+ "$(dmenu -p Search: -w $1 < /dev/null)\"", \
|
||||
+ "surf-search", winid, "_SURF_SEARCH", NULL \
|
||||
+ } \
|
||||
+}
|
||||
+
|
||||
/* DOWNLOAD(URI, referer) */
|
||||
#define DOWNLOAD(u, r) { \
|
||||
.v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
|
||||
@@ -133,6 +142,7 @@ static Key keys[] = {
|
||||
{ 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) },
|
||||
+ { MODKEY, GDK_KEY_s, spawn, SEARCH() },
|
||||
|
||||
{ 0, GDK_KEY_Escape, stop, { 0 } },
|
||||
{ MODKEY, GDK_KEY_c, stop, { 0 } },
|
||||
diff --git a/surf.c b/surf.c
|
||||
index 2b54e3c..077fb76 100644
|
||||
--- a/surf.c
|
||||
+++ b/surf.c
|
||||
@@ -35,7 +35,7 @@
|
||||
#define LENGTH(x) (sizeof(x) / sizeof(x[0]))
|
||||
#define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK))
|
||||
|
||||
-enum { AtomFind, AtomGo, AtomUri, AtomLast };
|
||||
+enum { AtomFind, AtomSearch, AtomGo, AtomUri, AtomLast };
|
||||
|
||||
enum {
|
||||
OnDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT,
|
||||
@@ -231,6 +231,7 @@ static void togglefullscreen(Client *c, const Arg *a);
|
||||
static void togglecookiepolicy(Client *c, const Arg *a);
|
||||
static void toggleinspector(Client *c, const Arg *a);
|
||||
static void find(Client *c, const Arg *a);
|
||||
+static void search(Client *c, const Arg *a);
|
||||
|
||||
/* Buttons */
|
||||
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
|
||||
@@ -326,6 +327,7 @@ setup(void)
|
||||
|
||||
/* atoms */
|
||||
atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
|
||||
+ atoms[AtomSearch] = XInternAtom(dpy, "_SURF_SEARCH", False);
|
||||
atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False);
|
||||
atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False);
|
||||
|
||||
@@ -577,6 +579,19 @@ loaduri(Client *c, const Arg *a)
|
||||
g_free(url);
|
||||
}
|
||||
|
||||
+void
|
||||
+search(Client *c, const Arg *a)
|
||||
+{
|
||||
+ Arg arg;
|
||||
+ char *url;
|
||||
+
|
||||
+ url = g_strdup_printf(searchurl, a->v);
|
||||
+ arg.v = url;
|
||||
+ loaduri(c, &arg);
|
||||
+
|
||||
+ g_free(url);
|
||||
+}
|
||||
+
|
||||
const char *
|
||||
geturi(Client *c)
|
||||
{
|
||||
@@ -1311,6 +1326,9 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d)
|
||||
find(c, NULL);
|
||||
|
||||
return GDK_FILTER_REMOVE;
|
||||
+ } else if (ev->atom == atoms[AtomSearch]) {
|
||||
+ a.v = getatom(c, AtomSearch);
|
||||
+ search(c, &a);
|
||||
} else if (ev->atom == atoms[AtomGo]) {
|
||||
a.v = getatom(c, AtomGo);
|
||||
loaduri(c, &a);
|
||||
--
|
||||
2.21.0
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,330 @@
|
|||
.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 \-p
|
||||
Disable Plugins.
|
||||
.TP
|
||||
.B \-P
|
||||
Enable Plugins.
|
||||
.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 Ctrl\-Shift\-v
|
||||
Toggle the enabling of plugins on that surf instance. 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 v V
|
||||
plugins
|
||||
.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 PLUGINS
|
||||
For using plugins in surf, first determine your running architecture. Then get
|
||||
the appropriate plugin for that architecture and copy it to
|
||||
.BR /usr/lib/browser-plugins
|
||||
or
|
||||
.BR /usr/lib64/browser-plugins.
|
||||
Surf should load them automatically.
|
||||
.BR
|
||||
If you want to use a 32bit plugin on a 64bit system,
|
||||
.BR nspluginwrapper(1)
|
||||
will help you.
|
||||
.SH SEE ALSO
|
||||
.BR dmenu(1),
|
||||
.BR xprop(1),
|
||||
.BR tabbed(1),
|
||||
.BR nspluginwrapper(1),
|
||||
.BR xdotool(1)
|
||||
.SH BUGS
|
||||
Please report them!
|
Loading…
Reference in New Issue