summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--config.h86
-rw-r--r--piper_webext.c13
-rw-r--r--piper_webext.h2
-rw-r--r--surf.c37
-rw-r--r--webext-piper.c4
6 files changed, 104 insertions, 45 deletions
diff --git a/Makefile b/Makefile
index 506afa5..ab81824 100644
--- a/Makefile
+++ b/Makefile
@@ -93,6 +93,13 @@ webext-clean:
-rm webext-piper.o
-rm webext-piper.so
+superauto:
+ make clean
+ make webext-clean
+ make
+ make webext-build
+ sudo make webext-install
+
diff --git a/config.h b/config.h
index b6b3126..e1ab406 100644
--- a/config.h
+++ b/config.h
@@ -20,7 +20,7 @@ static Parameter defconfig[ParameterLast] = {
[AccessWebcam] = { { .i = 0 }, },
[Certificate] = { { .i = 0 }, },
[CaretBrowsing] = { { .i = 0 }, },
- [CookiePolicies] = { { .v = "@Aa" }, },
+ [CookiePolicies] = { { .v = "a@A" }, },
[DefaultCharset] = { { .v = "UTF-8" }, },
[DiskCache] = { { .i = 1 }, },
[DNSPrefetch] = { { .i = 0 }, },
@@ -31,11 +31,11 @@ static Parameter defconfig[ParameterLast] = {
[HideBackground] = { { .i = 0 }, },
[Inspector] = { { .i = 0 }, },
[Java] = { { .i = 1 }, },
- [JavaScript] = { { .i = 1 }, },
+ [JavaScript] = { { .i = 0 }, },
[KioskMode] = { { .i = 0 }, },
[LoadImages] = { { .i = 1 }, },
[MediaManualPlay] = { { .i = 1 }, },
- [Plugins] = { { .i = 1 }, },
+ [Plugins] = { { .i = 0 }, },
[PreferredLanguages] = { { .v = (char *[]){ NULL } }, },
[RunInFullscreen] = { { .i = 0 }, },
[ScrollBars] = { { .i = 1 }, },
@@ -66,22 +66,36 @@ static WebKitFindOptions findopts = WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE |
#define PROMPT_GO "Go:"
#define PROMPT_FIND "Find:"
-/* SETPROP(readprop, setprop, prompt)*/
+// surf new window
#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\"", \
+ "| dmenu -p \"$4\")\" && xprop -id $1 -f $3 8s -set $3 \"$prop\"", \
"surf-setprop", winid, r, s, p, NULL \
} \
}
+#define SETPROP_OLD(p, q) { \
+ .v = (const char *[]){ "/bin/sh", "-c", \
+ "/home/miguel/bin/surf $2 OLD", \
+ p, q, winid, NULL \
+ } \
+}
+
+// surf existing window
+#define SETPROP_NEW(p, q) { \
+ .v = (const char *[]){ "/bin/sh", "-c", \
+ "/home/miguel/bin/surf $2 NEW", \
+ p, q, winid, NULL \
+ } \
+}
-/* DOWNLOAD(URI, referer) */
-#define DOWNLOAD(u, r) { \
- .v = (const char *[]){ "st", "-e", "/bin/sh", "-c",\
- "curl -g -L -J -O -A \"$1\" -b \"$2\" -c \"$2\"" \
- " -e \"$3\" \"$4\"; read", \
- "surf-download", useragent, cookiefile, r, u, NULL \
+// download with curl
+#define DOWNLOAD(d, r) { \
+ .v = (const char *[]){ "/bin/sh", "-c", \
+ "/usr/bin/xterm -e /bin/sh -c \"cd /home/miguel/temp; ls; /usr/bin/curl -g -L -J -O --user-agent '$1'" \
+ " --referer '$2' -b $3 -c $3 '$0'; sleep 1;\"", \
+ d, useragent, r, cookiefile, NULL \
} \
}
@@ -130,41 +144,40 @@ 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_o, spawn, SETPROP_OLD("_SURF_URI", "_SURF_GO") },
+ { GDK_SHIFT_MASK, GDK_KEY_o, spawn, SETPROP_NEW("_SURF_URI", "_SURF_GO") },
- { 0, GDK_KEY_Escape, stop, { 0 } },
- { MODKEY, GDK_KEY_c, stop, { 0 } },
+ { 0, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
+ { 0, GDK_KEY_n, find, { .i = +1 } },
+ { GDK_SHIFT_MASK , GDK_KEY_n, find, { .i = -1 } },
- { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
- { MODKEY, GDK_KEY_r, reload, { .i = 0 } },
+ { 0, GDK_KEY_s, stop, { 0 } },
+ { GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
+ { 0, GDK_KEY_r, reload, { .i = 0 } },
- { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
- { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
+ { MODKEY, GDK_KEY_i, navigate, { .i = +1 } },
+ { MODKEY, GDK_KEY_o, navigate, { .i = -1 } },
/* Currently we have to use scrolling steps that WebKit2GTK+ gives us
* d: step down, u: step up, r: step right, l:step left
* D: page down, U: page up */
- { MODKEY, GDK_KEY_j, scroll, { .i = 'd' } },
- { MODKEY, GDK_KEY_k, scroll, { .i = 'u' } },
- { MODKEY, GDK_KEY_b, scroll, { .i = 'U' } },
- { MODKEY, GDK_KEY_space, scroll, { .i = 'D' } },
- { MODKEY, GDK_KEY_i, scroll, { .i = 'r' } },
- { MODKEY, GDK_KEY_u, scroll, { .i = 'l' } },
+ { 0, GDK_KEY_j, scroll, { .i = 'd' } },
+ { 0, GDK_KEY_k, scroll, { .i = 'u' } },
+ { MODKEY, GDK_KEY_u, scroll, { .i = 'U' } },
+ { MODKEY, GDK_KEY_d, scroll, { .i = 'D' } },
+ { 0, GDK_KEY_l, scroll, { .i = 'r' } },
+ { 0, GDK_KEY_h, scroll, { .i = 'l' } },
+ { 0, GDK_KEY_g, scroll, { .i = 'H' } },
+ { GDK_SHIFT_MASK, GDK_KEY_g, scroll, { .i = 'E' } },
- { 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_KEY_BackSpace, zoom, { .i = 0 } },
+ { 0, GDK_KEY_minus, zoom, { .i = -1 } },
+ { 0, GDK_KEY_equal, zoom, { .i = +1 } },
- { 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 } },
{ MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
{ MODKEY, GDK_KEY_t, showcert, { 0 } },
@@ -195,6 +208,9 @@ static Key keys[] = {
{ 0, GDK_KEY_7, sendext, { .i = 7 } },
{ 0, GDK_KEY_8, sendext, { .i = 8 } },
{ 0, GDK_KEY_9, sendext, { .i = 9 } },
+ //insert mode toggle
+ { 0, GDK_KEY_Escape, toggle, { .i = KioskMode } },
+ { 0, GDK_KEY_i, toggle, { .i = KioskMode } },
};
diff --git a/piper_webext.c b/piper_webext.c
index 172039e..3d0d3c1 100644
--- a/piper_webext.c
+++ b/piper_webext.c
@@ -54,13 +54,22 @@ static int piper_lock(char *path)
return pipe;
}
-void piper_init(char *path_in,char *path_out,void (*callback_func)(char *msg))
+void piper_init(char *path_in,char *path_out,void (*callback_func)(char *msg),char *url)
{
pipe_in_callback=callback_func;
pipe_out_fd=piper_lock(path_out);
if(pipe_out_fd==-1)
{
- g_print("can not get exclusive lock! Bailing out.\n");
+ g_print("can not get exclusive lock! Sending messsage and Bailing out.\n");
+ if(url!=NULL)
+ {
+ gchar *fullpath=getpath(path_in);
+ int pipe=open(fullpath, O_RDWR | O_CREAT | O_TRUNC);
+ g_print("pipe fd: %i",pipe);
+ write(pipe,url,strlen(url));
+ write(pipe,"\n",1);
+ close(pipe);
+ }
exit(0);
}
register_callback(path_in);
diff --git a/piper_webext.h b/piper_webext.h
index 76de542..36d3aec 100644
--- a/piper_webext.h
+++ b/piper_webext.h
@@ -1,2 +1,2 @@
-void piper_init(char *pipe_in,char *pipe_out,void (*callback_func)(char *msg));
+void piper_init(char *pipe_in,char *pipe_out,void (*callback_func)(char *msg),char *url);
void piper_send(char *msg);
diff --git a/surf.c b/surf.c
index 4357b22..ffd4f0a 100644
--- a/surf.c
+++ b/surf.c
@@ -232,7 +232,7 @@ static void clicknewwindow(Client *c, const Arg *a, WebKitHitTestResult *h);
static void clickexternplayer(Client *c, const Arg *a, WebKitHitTestResult *h);
static char winid[64];
-static char togglestats[12];
+static char togglestats[13];
static char pagestats[2];
static Atom atoms[AtomLast];
static Window embed;
@@ -633,7 +633,8 @@ gettogglestats(Client *c)
togglestats[8] = curconfig[FrameFlattening].val.i ? 'F' : 'f';
togglestats[9] = curconfig[Certificate].val.i ? 'X' : 'x';
togglestats[10] = curconfig[StrictTLS].val.i ? 'T' : 't';
- togglestats[11] = '\0';
+ togglestats[11] = curconfig[KioskMode].val.i ? 'K' : 'k';
+ togglestats[12] = '\0';
}
void
@@ -1267,7 +1268,7 @@ winevent(GtkWidget *w, GdkEvent *e, Client *c)
updatetitle(c);
break;
case GDK_KEY_PRESS:
- if (!curconfig[KioskMode].val.i) {
+ if (!curconfig[KioskMode].val.i ^ e->key.keyval==GDK_KEY_Escape) {
for (i = 0; i < LENGTH(keys); ++i) {
if (gdk_keyval_to_lower(e->key.keyval) ==
keys[i].keyval &&
@@ -1692,9 +1693,18 @@ destroywin(GtkWidget* w, Client *c)
void
pasteuri(GtkClipboard *clipboard, const char *text, gpointer d)
{
+ char buf[1024];
Arg a = {.v = text };
if (text)
- loaduri((Client *) d, &a);
+ {
+ if (strstr(text, ".") == NULL) {
+ snprintf(buf,1024,"https://duckduckgo.com/?q=%s",text);
+ a.v = buf;
+ printf("%s\n",buf);
+ }
+ loaduri((Client *) d, &a);
+ }
+
}
void
@@ -1795,6 +1805,12 @@ scroll(Client *c, const Arg *a)
case 'u':
ev->key.keyval = GDK_KEY_Up;
break;
+ case 'H':
+ ev->key.keyval = GDK_KEY_Home;
+ break;
+ case 'E':
+ ev->key.keyval = GDK_KEY_End;
+ break;
}
gdk_event_put(ev);
@@ -1820,6 +1836,7 @@ toggle(Client *c, const Arg *a)
{
curconfig[a->i].val.i ^= 1;
setparameter(c, 1, (ParamName)a->i, &curconfig[a->i].val);
+ updatetitle(c);
}
void
@@ -1912,6 +1929,16 @@ void
piper_recv(char *msg)
{
g_print("message from extension: [%s]\n",msg);
+ Arg a;
+ a.v=msg;
+
+ Client *c = newclient(clients);
+ showview(NULL, c);
+
+ loaduri(c, &a);
+ updatetitle(c);
+
+
}
int
@@ -2056,7 +2083,7 @@ main(int argc, char *argv[])
else
arg.v = "about:blank";
- piper_init("ext-to-surf","surf-to-ext",piper_recv);
+ piper_init("ext-to-surf","surf-to-ext",piper_recv,arg.v);
setup();
c = newclient(NULL);
showview(NULL, c);
diff --git a/webext-piper.c b/webext-piper.c
index cae4da5..19fd8e9 100644
--- a/webext-piper.c
+++ b/webext-piper.c
@@ -85,7 +85,7 @@ void show_hints(WebKitDOMHTMLDocument *doc)
"top:%ipx;"\
"'>%03d</span>",
- CSS_CLASS_NAME,(int)webkit_dom_client_rect_get_left(rect),(int)webkit_dom_client_rect_get_top(rect),i);
+ CSS_CLASS_NAME,(int)webkit_dom_element_get_scroll_left(body)+(int)webkit_dom_client_rect_get_left(rect),(int)webkit_dom_element_get_scroll_top(body)+(int)webkit_dom_client_rect_get_top(rect),i);
webkit_dom_element_insert_adjacent_html (body,"beforeend",buf,NULL);
}
}
@@ -180,7 +180,7 @@ webkit_web_extension_initialize_with_user_data (WebKitWebExtension *extension,
GVariant *user_data)
{
g_print("webext started [%i]\n",getpid());
- piper_init("surf-to-ext","ext-to-surf",rcv);
+ piper_init("surf-to-ext","ext-to-surf",rcv,NULL);
g_signal_connect (extension, "page-created",
G_CALLBACK (page_created_callback),