surf

Mahdi's build of surf
git clone git://mahdi.pw/surf.git
Log | Files | Refs | README | LICENSE

commit 1d4f75dd128ca7e60f116a0c5c994a8fe04e1f43
parent 107fe086707b94e94990f2b83d83d13c47c3e32c
Author: Mahdi Mirzade <[email protected]>
Date:   Sun, 23 Oct 2022 20:37:24 +0330

webext: add missing gio/gunixfdlist.h includes
webext: use flags for gio-unix rather than gio

Diffstat:
Mconfig.h | 51++++++++++++++++++++++++++++-----------------------
Mconfig.mk | 6+++---
Msurf.c | 1+
Mwebext-surf.c | 1+
4 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/config.h b/config.h @@ -1,5 +1,5 @@ /* modifier 0 means no modifier */ -//#define HOMEPAGE "https://yandex.com/" +//#define HOMEPAGE "https://mahdi.pw" #define DOWNLOADS "~/Downloads" #define HS_FILE "~/.config/surf/history" #define BM_FILE "~/.config/surf/bookmarks" @@ -15,7 +15,7 @@ static char *cookiefile = "~/.config/surf/cookies.txt"; static char *bookmarkfile = BM_FILE; static char *historyfile = HS_FILE; -static char *searchengine = "https://yandex.com/search/?text="; +static char *searchengine = "https://lite.duckduckgo.com/lite/?q="; static SearchEngine searchengines[] = { { "wt", "https://www.wiktionary.org/search-redirect.php?family=wiktionary&search=%s" }, @@ -71,7 +71,10 @@ static UriParameters uriparams[] = { { "(://|\\.)(github\\.com|gitlab\\.com)(/|$)", { [JavaScript] = { { .i = 1 }, 1 }, }, }, - { "(://|\\.)(youtube\\.com|localhost:9091)(/|$)", { + { "(://|\\.)yewtu\\.be(/|$)", { + [JavaScript] = { { .i = 1 }, 1 }, + }, }, + { "(://|\\.)(localhost:9091|localhost:8080)(/|$)", { [JavaScript] = { { .i = 1 }, 1 }, [Style] = { { .i = 0 }, 1 }, }, }, @@ -92,26 +95,28 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE | /* SETPROP(readprop, setprop, prompt)*/ #define SETPROP(r, s, p) { \ - .v = (const char *[]){ "/bin/sh", "-c", \ - "WIDTH=\"$(xwininfo -id $1 | awk '/Width/{print int($2/5/3)}')\"; " \ - "HIST=\"$(tac " HS_FILE " 2>/dev/null | awk -F'|' '!a[$2]++')\"; " \ - "if [ \"${WIDTH}\" -lt 30 ]; then " \ - " HIST_TABLE=\"$(printf '%s\n' \"${HIST}\" | awk -F'|' '{print NR\"|\"$3}')\";" \ - "elif [ \"${WIDTH}\" -lt 50 ]; then" \ - " HIST_TABLE=\"$(printf '%s\n' \"${HIST}\" | awk -F'|' '{if(length($2) > '\"$WIDTH\"'){print NR\"|\"substr($2,0,'\"$WIDTH\"')\"...|\"$3}else{print NR\"|\"$2\"|\"$3}}')\"; " \ - "else HIST_TABLE=\"$(printf '%s\n' \"${HIST}\" | awk -F'|' '{if(length($2) > '\"$WIDTH\"'){print NR\"|\"$1\"|\"substr($2,0,'\"$WIDTH\"')\"...|\"$3}else{print NR\"|\"$1\"|\"$2\"|\"$3}}')\"; fi; " \ - "prop=\"$(printf '%b' \"$(xprop -id $1 "r" " \ - "| sed -e 's/^"r"(UTF8_STRING) = \"\\(.*\\)\"/\\1/' " \ - " -e 's/\\\\\\(.\\)/\\1/g' "\ - " && [ \""p"\" != \""PROMPT_FIND"\" ]" \ - " && cat " BM_FILE " 2>/dev/null " \ - " && printf '%s\n' \"${HIST_TABLE}\" | column -t -s '|' -o ' ')\" " \ - "| dmenu -i -b -l 20 -p '"p"' -w $1 | awk '{if(length($3)!=0){print $1}else{print $0}}')\"; " \ - "[ \"$prop\" ] || exit; " \ - "[ \"$(echo \"$prop\" | grep -Eo '^\-?[0-9]+$')\" -gt 0 ] && prop=\"$(printf '%s\n' \"${HIST}\" | sed \"${prop}q;d\" | awk -F'|' '{print $2}')\"; " \ - "if [ \""p"\" != \""PROMPT_NEW"\" ]; then xprop -id $1 -f "s" 8u -set "s" \"$prop\"; else surf-open \"$prop\"; fi", \ - "surf-setprop", winid, NULL \ - } \ + .v = (const char *[]){ "/bin/sh", "-c", \ + "WIDTH=$(xwininfo -id $1 | awk '/Width/{print int($2/20)}'); " \ + "HIST=$(tail -n 5000 " HS_FILE " 2>/dev/null | awk -F'|' '!a[$2]++' | sort -r); " \ + "if [ ${WIDTH} -lt 30 ]; then " \ + " HIST_TABLE=$(printf '%s\n' \"${HIST}\" | awk -F'|' '{print NR\"|\"$3}');" \ + "elif [ ${WIDTH} -lt 50 ]; then" \ + " HIST_TABLE=$(printf '%s\n' \"${HIST}\" | awk -F'|' '{if(length($2) > '\"$WIDTH\"'){print NR\"|\"substr($2,0,'\"$WIDTH\"')\"...|\"$3}else{print NR\"|\"$2\"|\"$3}}'); " \ + "else HIST_TABLE=$(printf '%s\n' \"${HIST}\" | awk -F'|' '{if(length($2) > '\"$WIDTH\"'){print NR\"|\"$1\"|\"substr($2,0,'\"$WIDTH\"')\"...|\"$3}else{print NR\"|\"$1\"|\"$2\"|\"$3}}'); fi; " \ + "BOOKMARKS=$(cat " BM_FILE " 2>/dev/null); " \ + "HISTORIES=$(printf '%s\n' \"${HIST_TABLE}\" | column -t -s '|'); " \ + "[ \"$HIST\" ] || HISTORIES=''; " \ + "prop=$(printf '%b' \"$(xprop -id $1 "r" " \ + "| sed -e 's/^"r"(UTF8_STRING) = \"\\(.*\\)\"/\\1/' " \ + " -e 's/\\\\\\(.\\)/\\1/g' "\ + " && [ \""p"\" != \""PROMPT_FIND"\" ]" \ + " && printf '%s\n' \"${BOOKMARKS:----Bookmarks go here---}\" \"${HISTORIES:----History records go here---}\")\" " \ + "| dmenu -i -b -l 20 -p '"p"' -w $1 | awk '{if(length($3)!=0){print $1}else{print $0}}'); " \ + "[ \"$prop\" ] || exit; " \ + "[ \"$(echo \"$prop\" | grep -Eo '^\-?[0-9]+$')\" -gt 0 ] && prop=\"$(printf '%s\n' \"${HIST}\" | sed \"${prop}q;d\" | awk -F'|' '{print $2}')\"; " \ + "if [ \""p"\" != \""PROMPT_NEW"\" ]; then xprop -id $1 -f "s" 8u -set "s" \"$prop\"; else surf-open \"$prop\"; fi", \ + "surf-setprop", winid, NULL \ + } \ } /* DOWNLOAD(URI, referer) */ diff --git a/config.mk b/config.mk @@ -14,11 +14,11 @@ 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` +WEBEXTINC = `pkg-config --cflags webkit2gtk-4.0 webkit2gtk-web-extension-4.0 gio-unix-2.0` +WEBEXTLIBS = `pkg-config --libs webkit2gtk-4.0 webkit2gtk-web-extension-4.0 gio-unix-2.0` # includes and libs -INCS = $(X11INC) $(GTKINC) +INCS = $(X11INC) $(GTKINC) -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include LIBS = $(X11LIB) $(GTKLIB) -lgthread-2.0 # flags diff --git a/surf.c b/surf.c @@ -21,6 +21,7 @@ #include <gdk/gdk.h> #include <gdk/gdkkeysyms.h> #include <gdk/gdkx.h> +#include <gio/gunixfdlist.h> #include <glib/gstdio.h> #include <gtk/gtk.h> #include <gtk/gtkx.h> diff --git a/webext-surf.c b/webext-surf.c @@ -7,6 +7,7 @@ #include <stdlib.h> #include <gio/gio.h> +#include <gio/gunixfdlist.h> #include <webkit2/webkit-web-extension.h> #include <webkitdom/webkitdom.h> #include <webkitdom/WebKitDOMDOMWindowUnstable.h>