summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--config.h (renamed from config.def.h)26
-rw-r--r--config.mk16
-rwxr-xr-xgitorigin.sh3
-rwxr-xr-xsurf-menu77
-rwxr-xr-xsurf-open.sh32
-rw-r--r--surf.c4
-rw-r--r--surf.desktop12
8 files changed, 123 insertions, 53 deletions
diff --git a/Makefile b/Makefile
index 4f5253a..f5a1dfb 100644
--- a/Makefile
+++ b/Makefile
@@ -60,16 +60,22 @@ install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f surf $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/surf
+ cp -f surf-menu $(DESTDIR)$(PREFIX)/bin
+ chmod 755 $(DESTDIR)$(PREFIX)/bin/surf-menu
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
+ mkdir -p $(DESTDIR)/usr/share/applications
+ cp -f surf.desktop $(DESTDIR)/usr/share/applications/surf.desktop
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/surf
+ rm -f $(DESTDIR)$(PREFIX)/bin/surf-menu
rm -f $(DESTDIR)$(MANPREFIX)/man1/surf.1
+ rm -f $(DESTDIR)/usr/share/applications/surf.desktop
rm -f $(DESTDIR)$(LIBDIR)/libsurf-webext.so
- rmdir $(DESTDIR)$(LIBDIR)
diff --git a/config.def.h b/config.h
index 34265f6..17af18a 100644
--- a/config.def.h
+++ b/config.h
@@ -18,12 +18,12 @@ static Parameter defconfig[ParameterLast] = {
[AcceleratedCanvas] = { { .i = 1 }, },
[AccessMicrophone] = { { .i = 0 }, },
[AccessWebcam] = { { .i = 0 }, },
- [Certificate] = { { .i = 0 }, },
+ [Certificate] = { { .i = 1 }, },
[CaretBrowsing] = { { .i = 0 }, },
[CookiePolicies] = { { .v = "@Aa" }, },
[DefaultCharset] = { { .v = "UTF-8" }, },
[DiskCache] = { { .i = 1 }, },
- [DNSPrefetch] = { { .i = 0 }, },
+ [DNSPrefetch] = { { .i = 1 }, },
[FileURLsCrossAccess] = { { .i = 0 }, },
[FontSize] = { { .i = 12 }, },
[FrameFlattening] = { { .i = 0 }, },
@@ -34,19 +34,19 @@ static Parameter defconfig[ParameterLast] = {
[JavaScript] = { { .i = 1 }, },
[KioskMode] = { { .i = 0 }, },
[LoadImages] = { { .i = 1 }, },
- [MediaManualPlay] = { { .i = 1 }, },
+ [MediaManualPlay] = { { .i = 0 }, },
[Plugins] = { { .i = 1 }, },
- [PreferredLanguages] = { { .v = (char *[]){ NULL } }, },
+ [PreferredLanguages] = { { .v = (char *[]){ "en_US", "cs_CZ", 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 }) }, },
+ [SmoothScrolling] = { { .i = 1 }, },
+ [SpellChecking] = { { .i = 1 }, },
+ [SpellLanguages] = { { .v = ((char *[]){ "en_US", "cs_CZ", NULL }) }, },
[StrictTLS] = { { .i = 1 }, },
[Style] = { { .i = 1 }, },
- [WebGL] = { { .i = 0 }, },
+ [WebGL] = { { .i = 1 }, },
[ZoomLevel] = { { .f = 1.0 }, },
};
@@ -63,7 +63,6 @@ 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)*/
@@ -76,9 +75,14 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
} \
}
+/* Goto */
+#define GOTO { \
+ .v = (const char *[]){ "/usr/bin/surf-menu", "--xid", winid, NULL } \
+}
+
/* DOWNLOAD(URI, referer) */
#define DOWNLOAD(u, r) { \
- .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
+ .v = (const char *[]){ "urxvt", "-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 \
@@ -130,7 +134,7 @@ static SiteSpecific certs[] = {
*/
static Key keys[] = {
/* modifier keyval function arg */
- { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
+ { MODKEY, GDK_KEY_g, spawn, GOTO },
{ MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
{ MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
diff --git a/config.mk b/config.mk
index 5e68e38..c147c40 100644
--- a/config.mk
+++ b/config.mk
@@ -1,21 +1,21 @@
# surf version
VERSION = 2.0
-# Customize below to fit your system
+PKG_CONFIG ?= pkg-config
# paths
-PREFIX = /usr/local
+PREFIX = /usr
MANPREFIX = $(PREFIX)/share/man
LIBPREFIX = $(PREFIX)/lib
LIBDIR = $(LIBPREFIX)/surf
-X11INC = `pkg-config --cflags x11`
-X11LIB = `pkg-config --libs x11`
+X11INC = $(shell $(PKG_CONFIG) --cflags x11)
+X11LIB = $(shell $(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`
+GTKINC = $(shell $(PKG_CONFIG) --cflags gtk+-3.0 gcr-3 webkit2gtk-4.0)
+GTKLIB = $(shell $(PKG_CONFIG) --libs gtk+-3.0 gcr-3 webkit2gtk-4.0)
+WEBEXTINC = $(shell $(PKG_CONFIG) --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0)
+WEBEXTLIBS = $(shell $(PKG_CONFIG) --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0)
# includes and libs
INCS = $(X11INC) $(GTKINC)
diff --git a/gitorigin.sh b/gitorigin.sh
new file mode 100755
index 0000000..ea07b48
--- /dev/null
+++ b/gitorigin.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+git remote add origin git://git.suckless.org/surf
+git fetch remote
diff --git a/surf-menu b/surf-menu
new file mode 100755
index 0000000..7b31f13
--- /dev/null
+++ b/surf-menu
@@ -0,0 +1,77 @@
+#!/bin/sh
+set -e
+
+# For wayland
+# Surf is unable to run under wayland. This overcomes that and forces it to use
+# xwayland instead.
+export GDK_BACKEND=x11
+
+BOOKMARDS=~/notes/bookmarks.md
+#HISTORY=~/notes/.surf_history # TODO history
+SOCKS_PROXY="socks://localhost:8123"
+
+open_uri() {
+ if [ -n "$xid" ]; then
+ xprop -id "$xid" -f "_SURF_GO" 8s -set "_SURF_GO" "$1"
+ else
+ surf "$1" &
+ fi
+}
+
+xid=""
+addch=""
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -h|--h)
+ echo "This is menu script for surf web browser."
+ echo "Usage: $0 [OPTION]..."
+ echo
+ echo "Options:"
+ echo " --help, -h"
+ echo " Print this help text."
+ echo " --xid XID"
+ echo " Instead of opening new surf instance set url to existing one"
+ echo " --socks"
+ echo " Use SOCKS proxy"
+ exit
+ ;;
+ --xid)
+ xid="$2"
+ shift
+ ;;
+ -a|--add)
+ shift
+ addch="$addch
+$1"
+ ;;
+ --socks)
+ export ALL_PROXY="$SOCKS_PROXY"
+ export http_proxy="$SOCKS_PROXY"
+ export https_proxy="$SOCKS_PROXY"
+ ;;
+ *)
+ echo "Unknown option $1" >&2
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+# If xid is given then as first one add current uri
+if [ -n "$xid" ]; then
+ addch="$(xprop -id "$xid" _SURF_URI | sed -n 's/.*(STRING) = "\(.*\)"/\1/p')"
+ dmenu_args="-w $xid -p Go:"
+fi
+
+# Note: Bookmarks starts with '* '
+choose="$addch
+$(sed -n 's/\* //p' "$BOOKMARDS")"
+
+echo "$choose" | sed '/^\s*$/d' | dmenu -p 'surf' $dmenu_args | while read L; do
+ if echo "$L" | grep -qE '^\?'; then # We do search on duckduckgo
+ open_uri "https://duckduckgo.com/?q=${L#?}&t=surf&kk=-1&ia=web"
+ else
+ open_uri "$L"
+ fi
+done
diff --git a/surf-open.sh b/surf-open.sh
deleted file mode 100755
index c22edc2..0000000
--- a/surf-open.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/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
-
diff --git a/surf.c b/surf.c
index 2b54e3c..b76f19c 100644
--- a/surf.c
+++ b/surf.c
@@ -1818,11 +1818,11 @@ clipboard(Client *c, const Arg *a)
{
if (a->i) { /* load clipboard uri */
gtk_clipboard_request_text(gtk_clipboard_get(
- GDK_SELECTION_PRIMARY),
+ GDK_SELECTION_CLIPBOARD),
pasteuri, c);
} else { /* copy uri */
gtk_clipboard_set_text(gtk_clipboard_get(
- GDK_SELECTION_PRIMARY), c->targeturi
+ GDK_SELECTION_CLIPBOARD), c->targeturi
? c->targeturi : geturi(c), -1);
}
}
diff --git a/surf.desktop b/surf.desktop
new file mode 100644
index 0000000..57ca5f8
--- /dev/null
+++ b/surf.desktop
@@ -0,0 +1,12 @@
+[Desktop Entry]
+Type=Application
+Version=1.0
+Name=Surf
+GenericName=Web Browser
+TryExec=/usr/bin/surf
+Exec=/usr/bin/surf %u
+Terminal=false
+Categories=Network;WebBrowser;
+StartupNotify=true
+StartupWMClass=Surf
+MimeType=x-scheme-handler/unknown;x-scheme-handler/about;x-scheme-handler/https;x-scheme-handler/http;text/html;text/xml;