@ -0,0 +1,32 @@ | |||
#!/bin/bash | |||
NOTES_FOLDER="$HOME/Documents/Notes" | |||
JSON_DB="$NOTES_FOLDER/books.yml" | |||
function exists_or_create() { | |||
if [[ -f "$2" ]]; then | |||
echo "Not Creating the note: File is already there" | |||
else | |||
echo -e "$1 \n$2" | |||
echo -e "# Book: $1\n" > "$2" | |||
cat <<EOF >> $JSON_DB | |||
- book: "$1" | |||
hash: "$(basename $2)" | |||
date: "$(date '+%d/%m/%Y %H:%M:%S')" | |||
EOF | |||
fi | |||
} | |||
function add_annotation() { | |||
xclip -out -selection clipboard >> "$1" | |||
echo -e "\n> <!!>\n" >> $1 | |||
} | |||
hashed_filename="$NOTES_FOLDER/$(md5sum "$1" | cut -f1 -d' ').md" | |||
filename=$(basename "$@") | |||
exists_or_create "$filename" "$hashed_filename" | |||
add_annotation "$hashed_filename" |
@ -0,0 +1 @@ | |||
.ccls-cache |
@ -0,0 +1,212 @@ | |||
/* 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 *styledir = "~/.surf/styles/"; | |||
static char *certdir = "~/.surf/certificates/"; | |||
static char *cachedir = "~/.surf/cache/"; | |||
static char *cookiefile = "~/.surf/cookies.txt"; | |||
<<<<<<< | |||
======= | |||
static char *scriptfiles[] = { | |||
"~/.surf/script.js", | |||
}; | |||
/* Webkit default features */ | |||
/* Highest priority value will be used. | |||
>>>>>>> | |||
static char **plugindirs = (char*[]){ | |||
"~/.surf/plugins/", | |||
LIBPREFIX "/mozilla/plugins/", | |||
NULL | |||
}; | |||
/* 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 }, }, | |||
[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 }, }, | |||
[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 }, }, | |||
[ClipboardNotPrimary] = { { .i = 1 }, }, | |||
}; | |||
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/\")\" " \ | |||
"| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \ | |||
"surf-setprop", winid, r, s, p, 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_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 } }, | |||
}; | |||
/* 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 }, | |||
}; | |||
#define HOMEPAGE "https://duckduckgo.com/" |
@ -0,0 +1,204 @@ | |||
/* 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 **plugindirs = (char*[]){ | |||
"~/.surf/plugins/", | |||
LIBPREFIX "/mozilla/plugins/", | |||
NULL | |||
}; | |||
/* 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 }, }, | |||
[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 }, }, | |||
[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 }, }, | |||
[ClipboardNotPrimary] = { { .i = 1 }, }, | |||
}; | |||
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/\")\" " \ | |||
"| dmenu -p \"$4\" -w $1)\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \ | |||
"surf-setprop", winid, r, s, p, 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_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 } }, | |||
}; | |||
/* 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 }, | |||
}; | |||
#define HOMEPAGE "https://duckduckgo.com/" |
@ -0,0 +1,138 @@ | |||
diff --git a/config.def.h b/config.def.h | |||
index a221c86..9840736 100644 | |||
--- a/config.def.h | |||
+++ b/config.def.h | |||
@@ -32,6 +32,16 @@ static Bool hidebackground = FALSE; | |||
} \ | |||
} | |||
+#define SELNAV { \ | |||
+ .v = (char *[]){ "/bin/sh", "-c", \ | |||
+ "prop=\"`xprop -id $0 _SURF_HIST" \ | |||
+ " | sed -e 's/^.[^\"]*\"//' -e 's/\"$//' -e 's/\\\\\\n/\\n/g'" \ | |||
+ " | dmenu -i -l 10`\"" \ | |||
+ " && xprop -id $0 -f _SURF_NAV 8s -set _SURF_NAV \"$prop\"", \ | |||
+ winid, NULL \ | |||
+ } \ | |||
+} | |||
+ | |||
/* DOWNLOAD(URI, referer) */ | |||
#define DOWNLOAD(d, r) { \ | |||
.v = (char *[]){ "/bin/sh", "-c", \ | |||
@@ -67,6 +77,7 @@ static Key keys[] = { | |||
{ MODKEY, GDK_l, navigate, { .i = +1 } }, | |||
{ MODKEY, GDK_h, navigate, { .i = -1 } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_h, selhist, SELNAV }, | |||
{ MODKEY, GDK_j, scroll_v, { .i = +1 } }, | |||
{ MODKEY, GDK_k, scroll_v, { .i = -1 } }, | |||
diff --git a/surf.c b/surf.c | |||
index cebd469..8b6d751 100644 | |||
--- a/surf.c | |||
+++ b/surf.c | |||
@@ -32,7 +32,7 @@ char *argv0; | |||
#define COOKIEJAR_TYPE (cookiejar_get_type ()) | |||
#define COOKIEJAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COOKIEJAR_TYPE, CookieJar)) | |||
-enum { AtomFind, AtomGo, AtomUri, AtomLast }; | |||
+enum { AtomFind, AtomGo, AtomUri, AtomHist, AtomNav, AtomLast }; | |||
typedef union Arg Arg; | |||
union Arg { | |||
@@ -137,6 +137,8 @@ static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec, | |||
Client *c); | |||
static void loaduri(Client *c, const Arg *arg); | |||
static void navigate(Client *c, const Arg *arg); | |||
+static void selhist(Client *c, const Arg *arg); | |||
+static void navhist(Client *c, const Arg *arg); | |||
static Client *newclient(void); | |||
static void newwindow(Client *c, const Arg *arg, gboolean noembed); | |||
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); | |||
@@ -649,6 +651,59 @@ navigate(Client *c, const Arg *arg) { | |||
webkit_web_view_go_back_or_forward(c->view, steps); | |||
} | |||
+static void | |||
+selhist(Client *c, const Arg *arg) { | |||
+ WebKitWebBackForwardList *lst; | |||
+ WebKitWebHistoryItem *cur; | |||
+ gint i; | |||
+ gchar *out; | |||
+ gchar *tmp; | |||
+ gchar *line; | |||
+ | |||
+ out = g_strdup(""); | |||
+ | |||
+ if(!(lst = webkit_web_view_get_back_forward_list(c->view))) | |||
+ return; | |||
+ | |||
+ for(i = webkit_web_back_forward_list_get_back_length(lst); i > 0; i--) { | |||
+ if(!(cur = webkit_web_back_forward_list_get_nth_item(lst, -i))) | |||
+ break; | |||
+ line = g_strdup_printf("%d: %s\n", -i, | |||
+ webkit_web_history_item_get_original_uri(cur)); | |||
+ tmp = g_strconcat(out, line, NULL); | |||
+ g_free(out); | |||
+ out = tmp; | |||
+ } | |||
+ | |||
+ if((cur = webkit_web_back_forward_list_get_nth_item(lst, 0))) { | |||
+ line = g_strdup_printf("%d: %s", 0, | |||
+ webkit_web_history_item_get_original_uri(cur)); | |||
+ tmp = g_strconcat(out, line, NULL); | |||
+ g_free(out); | |||
+ out = tmp; | |||
+ } | |||
+ | |||
+ for(i = 1; i <= webkit_web_back_forward_list_get_forward_length(lst); i++) { | |||
+ if(!(cur = webkit_web_back_forward_list_get_nth_item(lst, i))) | |||
+ break; | |||
+ line = g_strdup_printf("\n%d: %s", i, | |||
+ webkit_web_history_item_get_original_uri(cur)); | |||
+ tmp = g_strconcat(out, line, NULL); | |||
+ g_free(out); | |||
+ out = tmp; | |||
+ } | |||
+ | |||
+ setatom(c, AtomHist, out); | |||
+ g_free(out); | |||
+ spawn(c, arg); | |||
+} | |||
+ | |||
+static void | |||
+navhist(Client *c, const Arg *arg) { | |||
+ Arg a = { .i = atoi(arg->v) }; | |||
+ navigate(c, &a); | |||
+} | |||
+ | |||
static Client * | |||
newclient(void) { | |||
Client *c; | |||
@@ -805,6 +860,7 @@ newclient(void) { | |||
setatom(c, AtomFind, ""); | |||
setatom(c, AtomUri, "about:blank"); | |||
+ setatom(c, AtomHist, ""); | |||
if(hidebackground) | |||
webkit_web_view_set_transparent(c->view, TRUE); | |||
@@ -923,6 +979,9 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d) { | |||
arg.v = getatom(c, AtomGo); | |||
loaduri(c, &arg); | |||
return GDK_FILTER_REMOVE; | |||
+ } else if(ev->atom == atoms[AtomNav]) { | |||
+ arg.v = getatom(c, AtomNav); | |||
+ navhist(c, &arg); | |||
} | |||
} | |||
} | |||
@@ -1004,6 +1063,8 @@ setup(void) { | |||
atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False); | |||
atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False); | |||
atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False); | |||
+ atoms[AtomHist] = XInternAtom(dpy, "_SURF_HIST", False); | |||
+ atoms[AtomNav] = XInternAtom(dpy, "_SURF_NAV", False); | |||
/* dirs and files */ | |||
cookiefile = buildpath(cookiefile); |
@ -0,0 +1,59 @@ | |||
diff --git a/config.def.h b/config.def.h | |||
index 93a3d49..05d81de 100644 | |||
--- a/config.def.h | |||
+++ b/config.def.h | |||
@@ -65,6 +65,18 @@ static Bool allowgeolocation = TRUE; | |||
} \ | |||
} | |||
+#define ONLOAD(u) { \ | |||
+ .v = (char *[]){"/bin/sh", "-c", \ | |||
+ "~/.surf/omnibar addhist \"$0\"", u, NULL \ | |||
+ } \ | |||
+} | |||
+ | |||
+#define GOTO { \ | |||
+ .v = (char *[]){"/bin/sh", "-c", \ | |||
+ "~/.surf/omnibar goto \"$0\" \"$1\"", winid, "_SURF_GO", NULL \ | |||
+ } \ | |||
+} | |||
+ | |||
/* styles */ | |||
/* | |||
* The iteration will stop at the first match, beginning at the beginning of | |||
@@ -112,7 +124,7 @@ static Key keys[] = { | |||
{ MODKEY, GDK_o, source, { 0 } }, | |||
{ MODKEY|GDK_SHIFT_MASK,GDK_o, inspector, { 0 } }, | |||
- { MODKEY, GDK_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") }, | |||
+ { MODKEY, GDK_g, spawn, GOTO }, | |||
{ MODKEY, GDK_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, | |||
{ MODKEY, GDK_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, | |||
diff --git a/surf.c b/surf.c | |||
index f2170a4..c8fdab3 100644 | |||
--- a/surf.c | |||
+++ b/surf.c | |||
@@ -789,11 +789,11 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) | |||
WebKitWebDataSource *src; | |||
WebKitNetworkRequest *request; | |||
SoupMessage *msg; | |||
- char *uri; | |||
+ char *uri = geturi(c); | |||
+ Arg arg; | |||
switch (webkit_web_view_get_load_status (c->view)) { | |||
case WEBKIT_LOAD_COMMITTED: | |||
- uri = geturi(c); | |||
if (strstr(uri, "https://") == uri) { | |||
frame = webkit_web_view_get_main_frame(c->view); | |||
src = webkit_web_frame_get_data_source(frame); | |||
@@ -809,6 +809,8 @@ loadstatuschange(WebKitWebView *view, GParamSpec *pspec, Client *c) | |||
setstyle(c, getstyle(uri)); | |||
break; | |||
case WEBKIT_LOAD_FINISHED: | |||
+ arg = (Arg)ONLOAD(uri); | |||
+ spawn(NULL, &arg); | |||
c->progress = 100; | |||
updatetitle(c); | |||
if (diskcache) { |
@ -0,0 +1,238 @@ | |||
diff --git a/config.def.h b/config.def.h | |||
index 93a3d49..fa7935c 100644 | |||
--- a/config.def.h | |||
+++ b/config.def.h | |||
@@ -83,50 +83,51 @@ static SiteStyle styles[] = { | |||
* edit the CLEANMASK() macro. | |||
*/ | |||
static Key keys[] = { | |||
- /* modifier keyval function arg Focus */ | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_r, reload, { .b = TRUE } }, | |||
- { MODKEY, GDK_r, reload, { .b = FALSE } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_p, print, { 0 } }, | |||
- | |||
- { MODKEY, GDK_p, clipboard, { .b = TRUE } }, | |||
- { MODKEY, GDK_y, clipboard, { .b = FALSE } }, | |||
- | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_j, zoom, { .i = -1 } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_k, zoom, { .i = +1 } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_q, zoom, { .i = 0 } }, | |||
- { MODKEY, GDK_minus, zoom, { .i = -1 } }, | |||
- { MODKEY, GDK_plus, zoom, { .i = +1 } }, | |||
- | |||
- { MODKEY, GDK_l, navigate, { .i = +1 } }, | |||
- { MODKEY, GDK_h, navigate, { .i = -1 } }, | |||
- | |||
- { MODKEY, GDK_j, scroll_v, { .i = +1 } }, | |||
- { MODKEY, GDK_k, scroll_v, { .i = -1 } }, | |||
- { MODKEY, GDK_b, scroll_v, { .i = -10000 } }, | |||
- { MODKEY, GDK_space, scroll_v, { .i = +10000 } }, | |||
- { MODKEY, GDK_i, scroll_h, { .i = +1 } }, | |||
- { MODKEY, GDK_u, scroll_h, { .i = -1 } }, | |||
- | |||
- { 0, GDK_F11, fullscreen, { 0 } }, | |||
- { 0, GDK_Escape, stop, { 0 } }, | |||
- { MODKEY, GDK_o, source, { 0 } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_o, inspector, { 0 } }, | |||
- | |||
- { MODKEY, GDK_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") }, | |||
- { MODKEY, GDK_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, | |||
- { MODKEY, GDK_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, | |||
- | |||
- { MODKEY, GDK_n, find, { .b = TRUE } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_n, find, { .b = FALSE } }, | |||
- | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_c, toggle, { .v = "enable-caret-browsing" } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_i, toggle, { .v = "auto-load-images" } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_s, toggle, { .v = "enable-scripts" } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_v, toggle, { .v = "enable-plugins" } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_a, togglecookiepolicy, { 0 } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_m, togglestyle, { 0 } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars, { 0 } }, | |||
- { MODKEY|GDK_SHIFT_MASK,GDK_g, togglegeolocation, { 0 } }, | |||
+ /* modifier keyval function arg Focus */ | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_r, reload, { .b = TRUE } }, | |||
+ { MODKEY, GDK_KEY_r, reload, { .b = FALSE } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_p, print, { 0 } }, | |||
+ | |||
+ { MODKEY, GDK_KEY_p, clipboard, { .b = TRUE } }, | |||
+ { MODKEY, GDK_KEY_y, clipboard, { .b = FALSE } }, | |||
+ | |||
+ { 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_l, navigate, { .i = +1 } }, | |||
+ { MODKEY, GDK_KEY_h, navigate, { .i = -1 } }, | |||
+ | |||
+ { MODKEY, GDK_KEY_j, scroll_v, { .i = +1 } }, | |||
+ { MODKEY, GDK_KEY_k, scroll_v, { .i = -1 } }, | |||
+ { MODKEY, GDK_KEY_b, scroll_v, { .i = -10000 } }, | |||
+ { MODKEY, GDK_KEY_space, scroll_v, { .i = +10000 } }, | |||
+ { MODKEY, GDK_KEY_i, scroll_h, { .i = +1 } }, | |||
+ { MODKEY, GDK_KEY_u, scroll_h, { .i = -1 } }, | |||
+ | |||
+ { 0, GDK_KEY_F11, fullscreen, { 0 } }, | |||
+ { 0, GDK_KEY_Escape, stop, { 0 } }, | |||
+ { MODKEY, GDK_KEY_o, source, { 0 } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_o, inspector, { 0 } }, | |||
+ | |||
+ { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO") }, | |||
+ { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, | |||
+ { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND") }, | |||
+ | |||
+ { MODKEY, GDK_KEY_n, find, { .b = TRUE } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_n, find, { .b = FALSE } }, | |||
+ | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_c, toggle, { .v = "enable-caret-browsing" } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_i, toggle, { .v = "auto-load-images" } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_s, toggle, { .v = "enable-scripts" } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_v, toggle, { .v = "enable-plugins" } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_a, togglecookiepolicy, { 0 } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_m, togglestyle, { 0 } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_b, togglescrollbars, { 0 } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_KEY_g, togglegeolocation, { 0 } }, | |||
+ | |||
}; | |||
/* button definitions */ | |||
diff --git a/config.mk b/config.mk | |||
index 9f85ea4..a070f88 100644 | |||
--- a/config.mk | |||
+++ b/config.mk | |||
@@ -10,8 +10,8 @@ MANPREFIX = ${PREFIX}/share/man | |||
X11INC = /usr/X11R6/include | |||
X11LIB = /usr/X11R6/lib | |||
-GTKINC = `pkg-config --cflags gtk+-2.0 webkit-1.0` | |||
-GTKLIB = `pkg-config --libs gtk+-2.0 webkit-1.0` | |||
+GTKINC = `pkg-config --cflags gtk+-3.0 webkitgtk-3.0` | |||
+GTKLIB = `pkg-config --libs gtk+-3.0 webkitgtk-3.0` | |||
# includes and libs | |||
INCS = -I. -I/usr/include -I${X11INC} ${GTKINC} | |||
diff --git a/surf.c b/surf.c | |||
index 108485b..7a708d4 100644 | |||
--- a/surf.c | |||
+++ b/surf.c | |||
@@ -6,6 +6,7 @@ | |||
#include <X11/X.h> | |||
#include <X11/Xatom.h> | |||
#include <gtk/gtk.h> | |||
+#include <gtk/gtkx.h> | |||
#include <gdk/gdkx.h> | |||
#include <gdk/gdk.h> | |||
#include <gdk/gdkkeysyms.h> | |||
@@ -100,7 +101,7 @@ typedef struct { | |||
static Display *dpy; | |||
static Atom atoms[AtomLast]; | |||
static Client *clients = NULL; | |||
-static GdkNativeWindow embed = 0; | |||
+static Window embed = 0; | |||
static gboolean showxid = FALSE; | |||
static char winid[64]; | |||
static gboolean usingproxy = 0; | |||
@@ -627,9 +628,9 @@ getatom(Client *c, int a) | |||
unsigned long ldummy; | |||
unsigned char *p = NULL; | |||
- XGetWindowProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), | |||
- atoms[a], 0L, BUFSIZ, False, XA_STRING, | |||
- &adummy, &idummy, &ldummy, &ldummy, &p); | |||
+ XGetWindowProperty(dpy, GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(c->win))), | |||
+ atoms[a], 0L, BUFSIZ, False, XA_STRING, | |||
+ &adummy, &idummy, &ldummy, &ldummy, &p); | |||
if (p) | |||
strncpy(buf, (char *)p, LENGTH(buf)-1); | |||
else | |||
@@ -873,6 +874,7 @@ newclient(void) | |||
WebKitWebFrame *frame; | |||
GdkGeometry hints = { 1, 1 }; | |||
GdkScreen *screen; | |||
+ GdkWindow *window; | |||
gdouble dpi; | |||
char *ua; | |||
@@ -902,6 +904,10 @@ newclient(void) | |||
*/ | |||
gtk_window_set_role(GTK_WINDOW(c->win), "Surf"); | |||
} | |||
+ | |||
+ gtk_widget_realize(GTK_WIDGET(c->win)); | |||
+ window = gtk_widget_get_window(GTK_WIDGET(c->win)); | |||
+ | |||
gtk_window_set_default_size(GTK_WINDOW(c->win), 800, 600); | |||
g_signal_connect(G_OBJECT(c->win), | |||
"destroy", | |||
@@ -914,10 +920,10 @@ newclient(void) | |||
addaccelgroup(c); | |||
/* Pane */ | |||
- c->pane = gtk_vpaned_new(); | |||
+ c->pane = gtk_paned_new(GTK_ORIENTATION_VERTICAL); | |||
/* VBox */ | |||
- c->vbox = gtk_vbox_new(FALSE, 0); | |||
+ c->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); | |||
gtk_paned_pack1(GTK_PANED(c->pane), c->vbox, TRUE, TRUE); | |||
/* Webview */ | |||
@@ -999,8 +1005,8 @@ newclient(void) | |||
gtk_widget_show(c->win); | |||
gtk_window_set_geometry_hints(GTK_WINDOW(c->win), NULL, &hints, | |||
GDK_HINT_MIN_SIZE); | |||
- gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK); | |||
- gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c); | |||
+ gdk_window_set_events(window, GDK_ALL_EVENTS_MASK); | |||
+ gdk_window_add_filter(window, processx, c); | |||
webkit_web_view_set_full_content_zoom(c->view, TRUE); | |||
runscript(frame); | |||
@@ -1034,7 +1040,7 @@ newclient(void) | |||
* It is equivalent to firefox's "layout.css.devPixelsPerPx" setting. | |||
*/ | |||
if (zoomto96dpi) { | |||
- screen = gdk_window_get_screen(GTK_WIDGET(c->win)->window); | |||
+ screen = gdk_window_get_screen(window); | |||
dpi = gdk_screen_get_resolution(screen); | |||
if (dpi != -1) { | |||
g_object_set(G_OBJECT(settings), | |||
@@ -1073,7 +1079,7 @@ newclient(void) | |||
if (showxid) { | |||
gdk_display_sync(gtk_widget_get_display(c->win)); | |||
printf("%u\n", | |||
- (guint)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window)); | |||
+ (guint)GDK_WINDOW_XID(window)); | |||
fflush(NULL); | |||
if (fclose(stdout) != 0) | |||
die("Error closing stdout"); | |||
@@ -1281,7 +1287,7 @@ void | |||
setatom(Client *c, int a, const char *v) | |||
{ | |||
XSync(dpy, False); | |||
- XChangeProperty(dpy, GDK_WINDOW_XID(GTK_WIDGET(c->win)->window), | |||
+ XChangeProperty(dpy, GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(c->win))), | |||
atoms[a], XA_STRING, 8, PropModeReplace, | |||
(unsigned char *)v, strlen(v) + 1); | |||
} | |||
@@ -1302,7 +1308,7 @@ setup(void) | |||
die("Can't install SIGHUP handler"); | |||
gtk_init(NULL, NULL); | |||
- dpy = GDK_DISPLAY(); | |||
+ dpy = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); | |||
/* atoms */ | |||
atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False); | |||
@@ -1634,7 +1640,7 @@ void | |||
updatewinid(Client *c) | |||
{ | |||
snprintf(winid, LENGTH(winid), "%u", | |||
- (int)GDK_WINDOW_XID(GTK_WIDGET(c->win)->window)); | |||
+ (int)GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(c->win)))); | |||
} | |||
void | |||
@ -0,0 +1,93 @@ | |||
diff --git a/surf.c b/surf.c | |||
index 93a1629..ba53b94 100644 | |||
--- a/surf.c | |||
+++ b/surf.c | |||
@@ -217,6 +217,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 externalpipe(Client *c, const Arg *a); | |||
/* Buttons */ | |||
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h); | |||
@@ -241,6 +242,80 @@ char *argv0; | |||
/* configuration, allows nested code to access above variables */ | |||
#include "config.h" | |||
+static void | |||
+externalpipe_execute(char* buffer, Arg *arg) { | |||
+ int to[2]; | |||
+ void (*oldsigpipe)(int); | |||
+ | |||
+ if (pipe(to) == -1) | |||
+ return; | |||
+ | |||
+ switch (fork()) { | |||
+ case -1: | |||
+ close(to[0]); | |||
+ close(to[1]); | |||
+ return; | |||
+ case 0: | |||
+ dup2(to[0], STDIN_FILENO); close(to[0]); close(to[1]); | |||
+ execvp(((char **)arg->v)[0], (char **)arg->v); | |||
+ fprintf(stderr, "st: execvp %s\n", ((char **)arg->v)[0]); | |||
+ perror("failed"); | |||
+ exit(0); | |||
+ } | |||
+ | |||
+ close(to[0]); | |||
+ oldsigpipe = signal(SIGPIPE, SIG_IGN); | |||
+ write(to[1], buffer, strlen(buffer)); | |||
+ close(to[1]); | |||
+ signal(SIGPIPE, oldsigpipe); | |||
+} | |||
+ | |||
+static void | |||
+externalpipe_resource_done(WebKitWebResource *r, GAsyncResult *s, Arg *arg) | |||
+{ | |||
+ GError *gerr = NULL; | |||
+ guchar *buffer = webkit_web_resource_get_data_finish(r, s, NULL, &gerr); | |||
+ if (gerr == NULL) { | |||
+ externalpipe_execute((char *) buffer, arg); | |||
+ } else { | |||
+ g_error_free(gerr); | |||
+ } | |||
+ g_free(buffer); | |||
+} | |||
+ | |||
+static void | |||
+externalpipe_js_done(WebKitWebView *wv, GAsyncResult *s, Arg *arg) | |||
+{ | |||
+ WebKitJavascriptResult *j = webkit_web_view_run_javascript_finish( | |||
+ wv, s, NULL); | |||
+ if (!j) { | |||
+ return; | |||
+ } | |||
+ JSCValue *v = webkit_javascript_result_get_js_value(j); | |||
+ if (jsc_value_is_string(v)) { | |||
+ char *buffer = jsc_value_to_string(v); | |||
+ externalpipe_execute(buffer, arg); | |||
+ g_free(buffer); | |||
+ } | |||
+ webkit_javascript_result_unref(j); | |||
+} | |||
+ | |||
+void | |||
+externalpipe(Client *c, const Arg *arg) | |||
+{ | |||
+ if (curconfig[JavaScript].val.i) { | |||
+ webkit_web_view_run_javascript( | |||
+ c->view, "window.document.documentElement.outerHTML", | |||
+ NULL, externalpipe_js_done, arg); | |||
+ } else { | |||
+ WebKitWebResource *resource = webkit_web_view_get_main_resource(c->view); | |||
+ if (resource != NULL) { | |||
+ webkit_web_resource_get_data( | |||
+ resource, NULL, externalpipe_resource_done, arg); | |||
+ } | |||
+ } | |||
+} | |||
+ | |||
void | |||
usage(void) | |||
{ |
@ -0,0 +1,24 @@ | |||
diff --git a/config.def.h b/config.def.h | |||
--- a/config.def.h | |||
+++ b/config.def.h | |||
@@ -164,3 +164,5 @@ static Button buttons[] = { | |||
{ OnAny, 0, 9, clicknavigate, { .i = +1 }, 1 }, | |||
{ OnMedia, MODKEY, 1, clickexternplayer, { 0 }, 1 }, | |||
}; | |||
+ | |||
+#define HOMEPAGE "https://duckduckgo.com/" | |||
diff --git a/surf.c b/surf.c | |||
--- a/surf.c | |||
+++ b/surf.c | |||
@@ -1751,7 +1751,11 @@ main(int argc, char *argv[]) | |||
if (argc > 0) | |||
arg.v = argv[0]; | |||
else | |||
+#ifdef HOMEPAGE | |||
+ arg.v = HOMEPAGE; | |||
+#else | |||
arg.v = "about:blank"; | |||
+#endif | |||
setup(); | |||
c = newclient(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,67 @@ | |||
From a6a8878bb6a203b589d559025b94a78214f22878 Mon Sep 17 00:00:00 2001 | |||
From: Olivier Moreau <m242@protonmail.com> | |||
Date: Sun, 12 Jan 2020 11:23:11 +0000 | |||
Subject: [PATCH] Added choice between PRIMARY and CLIPBOARD Gtk selections, as | |||
a config option | |||
--- | |||
config.def.h | 1 + | |||
surf.c | 11 +++++++++-- | |||
2 files changed, 10 insertions(+), 2 deletions(-) | |||
diff --git a/config.def.h b/config.def.h | |||
index 34265f6..03bbe2b 100644 | |||
--- a/config.def.h | |||
+++ b/config.def.h | |||
@@ -48,6 +48,7 @@ static Parameter defconfig[ParameterLast] = { | |||
[Style] = { { .i = 1 }, }, | |||
[WebGL] = { { .i = 0 }, }, | |||
[ZoomLevel] = { { .f = 1.0 }, }, | |||
+ [ClipboardNotPrimary] = { { .i = 1 }, }, | |||
}; | |||
static UriParameters uriparams[] = { | |||
diff --git a/surf.c b/surf.c | |||
index 2b54e3c..b8a9b2f 100644 | |||
--- a/surf.c | |||
+++ b/surf.c | |||
@@ -82,6 +82,7 @@ typedef enum { | |||
Style, | |||
WebGL, | |||
ZoomLevel, | |||
+ ClipboardNotPrimary, | |||
ParameterLast | |||
} ParamName; | |||
@@ -291,6 +292,7 @@ static ParamName loadcommitted[] = { | |||
SpellLanguages, | |||
Style, | |||
ZoomLevel, | |||
+ ClipboardNotPrimary, | |||
ParameterLast | |||
}; | |||
@@ -1816,13 +1818,18 @@ showcert(Client *c, const Arg *a) | |||
void | |||
clipboard(Client *c, const Arg *a) | |||
{ | |||
+ /* User defined choice of selection, see config.h */ | |||
+ GdkAtom selection = GDK_SELECTION_PRIMARY; | |||
+ if (curconfig[ClipboardNotPrimary].val.i > 0) | |||
+ selection = GDK_SELECTION_CLIPBOARD; | |||
+ | |||
if (a->i) { /* load clipboard uri */ | |||
gtk_clipboard_request_text(gtk_clipboard_get( | |||
- GDK_SELECTION_PRIMARY), | |||
+ selection), | |||
pasteuri, c); | |||
} else { /* copy uri */ | |||
gtk_clipboard_set_text(gtk_clipboard_get( | |||
- GDK_SELECTION_PRIMARY), c->targeturi | |||
+ selection), c->targeturi | |||
? c->targeturi : geturi(c), -1); | |||
} | |||
} | |||
-- | |||
2.24.1 | |||
@ -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,134 @@ | |||
From 74a98d9600c50d50b9323cf8e459c88eb15da557 Mon Sep 17 00:00:00 2001 | |||
From: efe <efe@efe.kim> | |||
Date: Sat, 9 Feb 2019 13:16:51 -0500 | |||
Subject: [PATCH] Modal behaviour, 'i' to insert 'Esc' to get to the normal | |||
mode | |||
--- | |||
config.def.h | 53 +++++++++++++++++++++++++++------------------------- | |||
surf.c | 14 +++++++++++++- | |||
2 files changed, 41 insertions(+), 26 deletions(-) | |||
diff --git a/config.def.h b/config.def.h | |||
index 34265f6..8b7d5a2 100644 | |||
--- a/config.def.h | |||
+++ b/config.def.h | |||
@@ -130,41 +130,44 @@ 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_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, | |||
- { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, | |||
+ { 0, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) }, | |||
+ { 0, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, | |||
+ { 0, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) }, | |||
- { 0, GDK_KEY_Escape, stop, { 0 } }, | |||
- { MODKEY, GDK_KEY_c, stop, { 0 } }, | |||
+ { 0, GDK_KEY_i, insert, { .i = 1 } }, | |||
+ { 0, GDK_KEY_Escape, insert, { .i = 0 } }, | |||
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } }, | |||
- { MODKEY, GDK_KEY_r, reload, { .i = 0 } }, | |||
+ { 0, GDK_KEY_c, stop, { 0 } }, | |||
- { MODKEY, GDK_KEY_l, navigate, { .i = +1 } }, | |||
- { MODKEY, GDK_KEY_h, navigate, { .i = -1 } }, | |||
+ { MODKEY, GDK_KEY_r, reload, { .i = 1 } }, | |||
+ { 0, GDK_KEY_r, reload, { .i = 0 } }, | |||
+ | |||
+ { 0, GDK_KEY_l, navigate, { .i = +1 } }, | |||
+ { 0, 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 } }, | |||
+ { 0, GDK_KEY_j, scrollv, { .i = +10 } }, | |||
+ { 0, GDK_KEY_k, scrollv, { .i = -10 } }, | |||
+ { 0, GDK_KEY_space, scrollv, { .i = +50 } }, | |||
+ { 0, GDK_KEY_b, scrollv, { .i = -50 } }, | |||
+ { 0, GDK_KEY_i, scrollh, { .i = +10 } }, | |||
+ { 0, 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 } }, | |||
+ { 0|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } }, | |||
+ { 0|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } }, | |||
+ { 0|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } }, | |||
+ { 0, GDK_KEY_minus, zoom, { .i = -1 } }, | |||
+ { 0|GDK_SHIFT_MASK, GDK_KEY_plus, zoom, { .i = +1 } }, | |||
+ { 0, GDK_KEY_equal, zoom, { .i = 0 } }, | |||
- { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } }, | |||
- { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } }, | |||
+ { 0, GDK_KEY_p, clipboard, { .i = 1 } }, | |||
+ { 0, GDK_KEY_y, clipboard, { .i = 0 } }, | |||
- { MODKEY, GDK_KEY_n, find, { .i = +1 } }, | |||
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } }, | |||
+ { 0, GDK_KEY_n, find, { .i = +1 } }, | |||
+ { 0|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } }, | |||
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } }, | |||
+ { MODKEY, GDK_KEY_p, print, { 0 } }, | |||
{ MODKEY, GDK_KEY_t, showcert, { 0 } }, | |||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } }, | |||
diff --git a/surf.c b/surf.c | |||
index 2b54e3c..f4cbe68 100644 | |||
--- a/surf.c | |||
+++ b/surf.c | |||
@@ -175,6 +175,7 @@ static void spawn(Client *c, const Arg *a); | |||
static void msgext(Client *c, char type, const Arg *a); | |||
static void destroyclient(Client *c); | |||
static void cleanup(void); | |||
+static int insertmode = 0; | |||
/* GTK/WebKit */ | |||
static WebKitWebView *newview(Client *c, WebKitWebView *rv); | |||
@@ -231,6 +232,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 insert(Client *c, const Arg *a); | |||
/* Buttons */ | |||
static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h); | |||
@@ -1333,7 +1335,11 @@ winevent(GtkWidget *w, GdkEvent *e, Client *c) | |||
updatetitle(c); | |||
break; | |||
case GDK_KEY_PRESS: | |||
- if (!curconfig[KioskMode].val.i) { | |||
+ if (!curconfig[KioskMode].val.i && | |||
+ !insertmode || | |||
+ CLEANMASK(e->key.state) == (MODKEY|GDK_SHIFT_MASK) || | |||
+ CLEANMASK(e->key.state) == (MODKEY) || | |||
+ gdk_keyval_to_lower(e->key.keyval) == (GDK_KEY_Escape)) { | |||
for (i = 0; i < LENGTH(keys); ++i) { | |||
if (gdk_keyval_to_lower(e->key.keyval) == | |||
keys[i].keyval && | |||
@@ -1947,6 +1953,12 @@ find(Client *c, const Arg *a) | |||
} | |||
} | |||
+void | |||
+insert(Client *c, const Arg *a) | |||
+{ | |||
+ insertmode = (a->i); | |||
+} | |||
+ | |||
void | |||
clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h) | |||
{ | |||
-- | |||
2.20.1 | |||
@ -0,0 +1,101 @@ | |||
From 8d8ca34a8e61733711e23ce43b88435bfdfd4962 Mon Sep 17 00:00:00 2001 | |||
From: knary <theknary@gmail.com> | |||
Date: Mon, 25 Mar 2019 15:03:15 -0400 | |||
Subject: [PATCH] This patch replaces scriptfile with an array of | |||
scriptfiles[]. This allows for the inclusion of multiple javascript files | |||
instead of filling up one file with multiple script plugins. | |||
--- | |||
config.def.h | 4 +++- | |||
surf.c | 23 +++++++++++++++-------- | |||
2 files changed, 18 insertions(+), 9 deletions(-) | |||
diff --git a/config.def.h b/config.def.h | |||
index 34265f6..7d7d68e 100644 | |||
--- a/config.def.h | |||
+++ b/config.def.h | |||
@@ -1,11 +1,13 @@ | |||
/* 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 *scriptfiles[] = { | |||
+ "~/.surf/script.js", | |||
+}; | |||
/* Webkit default features */ | |||
/* Highest priority value will be used. | |||
diff --git a/surf.c b/surf.c | |||
index 2b54e3c..34a75de 100644 | |||
--- a/surf.c | |||
+++ b/surf.c | |||
@@ -337,9 +337,11 @@ setup(void) | |||
/* dirs and files */ | |||
cookiefile = buildfile(cookiefile); | |||
- scriptfile = buildfile(scriptfile); | |||
cachedir = buildpath(cachedir); | |||
certdir = buildpath(certdir); | |||
+ for (i = 0; i < LENGTH(scriptfiles); i++) { | |||
+ scriptfiles[i] = buildfile(scriptfiles[i]); | |||
+ } | |||
gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy)); | |||
@@ -945,9 +947,11 @@ runscript(Client *c) | |||
gchar *script; | |||
gsize l; | |||
- if (g_file_get_contents(scriptfile, &script, &l, NULL) && l) | |||
- evalscript(c, "%s", script); | |||
- g_free(script); | |||
+ for (int i = 0; i < LENGTH(scriptfiles); i++) { | |||
+ if (g_file_get_contents(scriptfiles[i], &script, &l, NULL) && l) | |||
+ evalscript(c, "%s", script); | |||
+ g_free(script); | |||
+ } | |||
} | |||
void | |||
@@ -1010,9 +1014,9 @@ newwindow(Client *c, const Arg *a, int noembed) | |||
cmd[i++] = curconfig[Style].val.i ? "-M" : "-m" ; | |||
cmd[i++] = curconfig[Inspector].val.i ? "-N" : "-n" ; | |||
cmd[i++] = curconfig[Plugins].val.i ? "-P" : "-p" ; | |||
- if (scriptfile && g_strcmp0(scriptfile, "")) { | |||
+ if (scriptfiles[0] && g_strcmp0(scriptfiles[0], "")) { | |||
cmd[i++] = "-r"; | |||
- cmd[i++] = scriptfile; | |||
+ cmd[i++] = scriptfiles[0]; | |||
} | |||
cmd[i++] = curconfig[JavaScript].val.i ? "-S" : "-s"; | |||
cmd[i++] = curconfig[StrictTLS].val.i ? "-T" : "-t"; | |||
@@ -1076,9 +1080,12 @@ cleanup(void) | |||
close(pipein[0]); | |||
close(pipeout[1]); | |||
g_free(cookiefile); | |||
- g_free(scriptfile); | |||
g_free(stylefile); | |||
g_free(cachedir); | |||
+ for (int i = 0; i < LENGTH(scriptfiles); i++) { | |||
+ g_free(scriptfiles[i]); | |||
+ } | |||
+ | |||
XCloseDisplay(dpy); | |||
} | |||
@@ -2067,7 +2074,7 @@ main(int argc, char *argv[]) | |||
defconfig[Plugins].prio = 2; | |||
break; | |||
case 'r': | |||
- scriptfile = EARGF(usage()); | |||
+ scriptfiles[0] = EARGF(usage()); | |||
break; | |||
case 's': | |||
defconfig[JavaScript].val.i = 0; | |||
-- | |||
2.21.0 | |||
@ -0,0 +1,26 @@ | |||
diff --git a/config.def.h b/config.def.h | |||
index 6d3135e..75dc6a6 100644 | |||
--- a/config.def.h | |||
+++ b/config.def.h | |||
@@ -153,6 +153,8 @@ static Key keys[] = { | |||
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_m, toggle, { .i = Style } }, | |||
}; | |||
+static char *searchengine = "https://duckduckgo.com/?q="; | |||
+ | |||
/* button definitions */ | |||
/* target can be OnDoc, OnLink, OnImg, OnMedia, OnEdit, OnBar, OnSel, OnAny */ | |||
static Button buttons[] = { | |||
diff --git a/surf.c b/surf.c | |||
index 93a1629..c20537e 100644 | |||
--- a/surf.c | |||
+++ b/surf.c | |||
@@ -476,6 +476,8 @@ loaduri(Client *c, const Arg *a) | |||
} else if (!stat(uri, &st) && (path = realpath(uri, NULL))) { | |||
url = g_strdup_printf("file://%s", path); | |||
free(path); | |||
+ } else if (*uri == ' ') { | |||
+ url = g_strdup_printf("%s%s", searchengine, uri + 1); | |||
} else { | |||
url = g_strdup_printf("http://%s", uri); | |||
} |
@ -0,0 +1,138 @@ | |||
diff --git a/config.def.h b/config.def.h | |||
index 5245129..604028f 100644 | |||
--- a/config.def.h | |||
+++ b/config.def.h | |||
@@ -45,6 +45,16 @@ static Bool allowgeolocation = TRUE; | |||
} \ | |||
} | |||
+#define SELNAV { \ | |||
+ .v = (char *[]){ "/bin/sh", "-c", \ | |||
+ "prop=\"`xprop -id $0 _SURF_HIST" \ | |||
+ " | sed -e 's/^.[^\"]*\"//' -e 's/\"$//' -e 's/\\\\\\n/\\n/g'" \ | |||
+ " | dmenu -i -l 10`\"" \ | |||
+ " && xprop -id $0 -f _SURF_NAV 8s -set _SURF_NAV \"$prop\"", \ | |||
+ winid, NULL \ | |||
+ } \ | |||
+} | |||
+ | |||
/* DOWNLOAD(URI, referer) */ | |||
#define DOWNLOAD(d, r) { \ | |||
.v = (char *[]){ "/bin/sh", "-c", \ | |||
@@ -99,6 +109,7 @@ static Key keys[] = { | |||
{ MODKEY, GDK_l, navigate, { .i = +1 } }, | |||
{ MODKEY, GDK_h, navigate, { .i = -1 } }, | |||
+ { MODKEY|GDK_SHIFT_MASK,GDK_h, selhist, SELNAV }, | |||
{ MODKEY, GDK_j, scroll_v, { .i = +1 } }, | |||
{ MODKEY, GDK_k, scroll_v, { .i = -1 } }, | |||
diff --git a/surf.c b/surf.c | |||
index 0fae80b..1c09336 100644 | |||
--- a/surf.c | |||
+++ b/surf.c | |||
@@ -36,7 +36,7 @@ char *argv0; | |||
#define COOKIEJAR_TYPE (cookiejar_get_type ()) | |||
#define COOKIEJAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COOKIEJAR_TYPE, CookieJar)) | |||
-enum { AtomFind, AtomGo, AtomUri, AtomLast }; | |||
+enum { AtomFind, AtomGo, AtomUri, AtomHist, AtomNav, AtomLast }; | |||
enum { | |||
ClkDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT, | |||
ClkLink = WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK, | |||
@@ -177,6 +177,8 @@ static void loadstatuschange(WebKitWebView *view, GParamSpec *pspec, | |||
Client *c); | |||
static void loaduri(Client *c, const Arg *arg); | |||
static void navigate(Client *c, const Arg *arg); | |||
+static void selhist(Client *c, const Arg *arg); | |||
+static void navhist(Client *c, const Arg *arg); | |||
static Client *newclient(void); | |||
static void newwindow(Client *c, const Arg *arg, gboolean noembed); | |||
static void pasteuri(GtkClipboard *clipboard, const char *text, gpointer d); | |||
@@ -813,6 +815,59 @@ navigate(Client *c, const Arg *arg) { | |||
webkit_web_view_go_back_or_forward(c->view, steps); | |||
} | |||
+static void | |||
+selhist(Client *c, const Arg *arg) { | |||
+ WebKitWebBackForwardList *lst; | |||
+ WebKitWebHistoryItem *cur; | |||
+ gint i; | |||
+ gchar *out; | |||
+ gchar *tmp; | |||
+ gchar *line; | |||
+ | |||
+ out = g_strdup(""); | |||
+ | |||
+ if(!(lst = webkit_web_view_get_back_forward_list(c->view))) | |||
+ return; | |||
+ | |||
+ for(i = webkit_web_back_forward_list_get_back_length(lst); i > 0; i--) { | |||
+ if(!(cur = webkit_web_back_forward_list_get_nth_item(lst, -i))) | |||
+ break; | |||
+ line = g_strdup_printf("%d: %s\n", -i, | |||
+ webkit_web_history_item_get_original_uri(cur)); | |||
+ tmp = g_strconcat(out, line, NULL); | |||
+ g_free(out); | |||
+ out = tmp; | |||
+ } | |||
+ | |||
+ if((cur = webkit_web_back_forward_list_get_nth_item(lst, 0))) { | |||
+ line = g_strdup_printf("%d: %s", 0, | |||
+ webkit_web_history_item_get_original_uri(cur)); | |||
+ tmp = g_strconcat(out, line, NULL); | |||
+ g_free(out); | |||
+ out = tmp; | |||
+ } | |||
+ | |||
+ for(i = 1; i <= webkit_web_back_forward_list_get_forward_length(lst); i++) { | |||
+ if(!(cur = webkit_web_back_forward_list_get_nth_item(lst, i))) | |||
+ break; | |||
+ line = g_strdup_printf("\n%d: %s", i, | |||
+ webkit_web_history_item_get_original_uri(cur)); | |||
+ tmp = g_strconcat(out, line, NULL); | |||
+ g_free(out); | |||
+ out = tmp; | |||
+ } | |||
+ | |||
+ setatom(c, AtomHist, out); | |||
+ g_free(out); | |||
+ spawn(c, arg); | |||
+} | |||
+ | |||
+static void | |||
+navhist(Client *c, const Arg *arg) { | |||
+ Arg a = { .i = atoi(arg->v) }; | |||
+ navigate(c, &a); | |||
+} | |||
+ | |||
static Client * | |||
newclient(void) { | |||
Client *c; | |||
@@ -1014,6 +1069,7 @@ newclient(void) { | |||
setatom(c, AtomFind, ""); | |||
setatom(c, AtomUri, "about:blank"); | |||
+ setatom(c, AtomHist, ""); | |||
if(hidebackground) | |||
webkit_web_view_set_transparent(c->view, TRUE); | |||
@@ -1153,6 +1209,9 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d) { | |||
loaduri(c, &arg); | |||
return GDK_FILTER_REMOVE; | |||
+ } else if(ev->atom == atoms[AtomNav]) { | |||
+ arg.v = getatom(c, AtomNav); | |||
+ navhist(c, &arg); | |||
} | |||
} | |||
} | |||
@@ -1247,6 +1306,8 @@ setup(void) { | |||
atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False); | |||
atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False); | |||
atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False); | |||
+ atoms[AtomHist] = XInternAtom(dpy, "_SURF_HIST", False); | |||
+ atoms[AtomNav] = XInternAtom(dpy, "_SURF_NAV", False); | |||
/* dirs and files */ | |||
cookiefile = buildfile(cookiefile); |