diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | AUTHORS | 2 | ||||
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | Makefile-new-test | 5 | ||||
-rw-r--r-- | README | 16 | ||||
-rw-r--r-- | config.h | 2 | ||||
-rw-r--r-- | docs/FAQ | 2 | ||||
-rw-r--r-- | docs/INSTALL | 3 | ||||
-rw-r--r-- | examples/config/uzbl/config | 5 | ||||
-rwxr-xr-x | examples/data/uzbl/scripts/history.sh | 3 | ||||
-rwxr-xr-x | examples/data/uzbl/scripts/load_url_from_bookmarks.sh | 2 | ||||
-rwxr-xr-x | examples/data/uzbl/scripts/load_url_from_history.sh | 2 | ||||
-rw-r--r-- | uzbl.c | 20 | ||||
-rw-r--r-- | uzbl.h | 4 | ||||
-rw-r--r-- | uzblctrl.c | 71 |
15 files changed, 23 insertions, 124 deletions
@@ -1,5 +1,4 @@ uzbl -uzblctrl uzbl.o *~ tags @@ -29,7 +29,7 @@ Contributors: (kmeaw) - fix for multibyte utf8 characters segfault (evocallaghan) - tiny patches Aaron Griffin (phrakture) - Makefile patches to build on OSX - Mason Larobina - os.environ.keys() & os.path.join fix in cookies.py, work on uzbl_tabbed.py + Mason Larobina - os.environ.keys() & os.path.join fix in cookies.py, work on uzbl_tabbed.py, cookies_daemon.py (dequis) - Uzbl.run, birectional socket, javascript commands Brendan Taylor (bct) - various bugfixes, making misc variables much better using expand(), refactoring some internal var stuff Chris van Dijk (quigybo) - work on uzbl_tabbed.py @@ -6,9 +6,9 @@ CFLAGS!=echo -std=c99 `pkg-config --cflags gtk+-2.0 webkit-1.0 libsoup-2.4 gthre LDFLAGS:=$(shell pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0) -pthread $(LDFLAGS) LDFLAGS!=echo `pkg-config --libs gtk+-2.0 webkit-1.0 libsoup-2.4 gthread-2.0` -pthread $(LDFLAGS) -all: uzbl uzblctrl +all: uzbl -PREFIX?=$(DESTDIR)/usr +PREFIX?=$(DESTDIR)/usr/local # When compiling unit tests, compile uzbl as a library first tests: uzbl.o @@ -22,12 +22,11 @@ test-dev: uzbl XDG_DATA_HOME=./examples/data XDG_CONFIG_HOME=./examples/config ./uzbl --uri http://www.uzbl.org --verbose test-share: uzbl - XDG_DATA_HOME=/usr/share/uzbl/examples/data XDG_CONFIG_HOME=/usr/share/uzbl/examples/config ./uzbl --uri http://www.uzbl.org --verbose + XDG_DATA_HOME=${PREFIX}/share/uzbl/examples/data XDG_CONFIG_HOME=${PREFIX}/share/uzbl/examples/config ./uzbl --uri http://www.uzbl.org --verbose clean: rm -f uzbl - rm -f uzblctrl rm -f uzbl.o cd ./tests/; $(MAKE) clean @@ -36,7 +35,6 @@ install: install -d $(PREFIX)/share/uzbl/docs install -d $(PREFIX)/share/uzbl/examples install -m755 uzbl $(PREFIX)/bin/uzbl - install -m755 uzblctrl $(PREFIX)/bin/uzblctrl cp -rp docs $(PREFIX)/share/uzbl/ cp -rp config.h $(PREFIX)/share/uzbl/docs/ cp -rp examples $(PREFIX)/share/uzbl/ @@ -46,5 +44,4 @@ install: uninstall: rm -rf $(PREFIX)/bin/uzbl - rm -rf $(PREFIX)/bin/uzblctrl rm -rf $(PREFIX)/share/uzbl diff --git a/Makefile-new-test b/Makefile-new-test index 9f85a4e..a1efa56 100644 --- a/Makefile-new-test +++ b/Makefile-new-test @@ -12,7 +12,7 @@ UZBLDATA ?= $(PREFIX)/share/uzbl DOCSDIR ?= $(PREFIX)/share/uzbl/docs EXMPLSDIR ?= $(PREFIX)/share/uzbl/examples -all: uzbl uzblctrl +all: uzbl uzbl: uzbl.c uzbl.h config.h @@ -30,14 +30,12 @@ test-config-real: uzbl clean: rm -f uzbl - rm -f uzblctrl install: install -d $(BINDIR) install -d $(DOCSDIR) install -d $(EXMPLSDIR) install -D -m755 uzbl $(BINDIR)/uzbl - install -D -m755 uzblctrl $(BINDIR)/uzblctrl cp -ax docs/* $(DOCSDIR) cp -ax config.h $(DOCSDIR) cp -ax examples/* $(EXMPLSDIR) @@ -47,5 +45,4 @@ install: uninstall: rm -rf $(BINDIR)/uzbl - rm -rf $(BINDIR)/uzblctrl rm -rf $(UZBLDATA) @@ -44,7 +44,7 @@ Time to change that! - privoxy looks cool and perfectly demonstrates the unix philosphy. - same for http://bfilter.sourceforge.net - /etc/hosts (not very good cause you need root and it affects the whole system) - uzblctrl would need to support an option to list all images on a page, so you can easily pick the links to ads to add them to your /etc/hosts. + one can list all images on a page using the socket, so you can easily pick the links to ads to add them to your /etc/hosts. * vimperator/konqueror-like hyperlink following. * password management. maybe an encrypted store that unlocks with an ssh key? * no messing in the users $HOME or in /etc: no writing of anything unless the user (or sysadmin) asks for it. @@ -73,9 +73,8 @@ There are several interfaces to interact with uzbl: * shift insert (paste primary selection buffer) * FIFO & socket file: if enabled by setting their paths through one of the above means, you can have socket and fifo files available which are very useful to programatically control uzbl (from scripts etc). The advantage of the fifo is you can write plaintxt commands to it, but it's half duplex only (uzbl cannot send a response to you). - The socket is full duplex but you need a socket-compatible wrapper such as netcat to work with it, or uzblctrl of course, - an utitly we include with uzbl made especially for writing commnands to the socket (and at some point, it will be able to tell you the response - too): `uzblctrl -s <socketfile> -c <command>` + The socket is full duplex but you need a socket-compatible wrapper such as socat to work with it. + For example: echo <command> | socat - unix-connect:<socketfile> When uzbl forks a new instance (eg "open in new window") it will use the same commandline arguments (eg the same --config <file>), except --uri and--name. If you made changes to the configuration at runtime, these are not pased on to the child. @@ -196,7 +195,6 @@ Besides the builtin variables you can also define your own ones and use them in - load_finish_handler - load_start_handler - load_commit_handler - - history_handler - download_handler - cookie_handler - new_window: handler to execute to invoke new uzbl window (TODO better name) @@ -206,8 +204,8 @@ Besides the builtin variables you can also define your own ones and use them in - http_debug: http debug mode (value 0-3) - shell_cmd: alias which will be expanded to use shell commands (eg sh -c) - proxy_url: http traffic socks proxy (eg: http://<host>:<port>) - - max_conns - - max_conns_host + - max_conns: max simultaneous connections (default: 100) + - max_conns_host: max simultaneous connections per hostname (default: 6) - useragent: to be expanded strin - zoom_level - font_size @@ -354,10 +352,6 @@ Handler scripts that are called by uzbl are passed the following arguments: The script specific arguments are this: -* history: - - $8 date of visit (Y-m-d H:i:s localtime) - * add bookmark: none @@ -5,5 +5,7 @@ const struct { { "set status_format = <span background=\"darkblue\" foreground=\"white\"> \\@MODE </span> <span background=\"red\" foreground=\"white\">\\@[\\@keycmd]\\@</span> (\\@LOAD_PROGRESS%) <b>\\@[\\@TITLE]\\@</b> - Uzbl browser"}, { "set title_format_long = \\@keycmd \\@MODE \\@TITLE - Uzbl browser <\\@NAME> > \\@SELECTED_URI"}, { "set title_format_short = \\@TITLE - Uzbl browser <\\@NAME>"}, +{ "set max_conns = 100"}, /* WebkitGTK default: 10 */ +{ "set max_conns_host = 6"}, /* WebkitGTK default: 2 */ { NULL } }; @@ -112,7 +112,7 @@ Yes, Webkit takes care of all of that. Not that we like all of these, but you c They both have advantages and disadvantages: * fifo's are _very_ easy to work with. You can write just plaintext commands into them, but they are unidirectional (you can only communicate in one direction) - * Sockets are bidirectional but more complex. You cannot just write a plaintext string into them. In shellscripts you can use uzblctrl or netcat to work with sockets, when programming you need to use library functions. + * Sockets are bidirectional but more complex. You cannot just write a plaintext string into them. In shellscripts you can use socat to work with sockets, when programming you need to use library functions. So, when writing scripts, using fifo's is usually the fastest method (because you do not need to fork another process), so fifo is preferred unless you need a response. diff --git a/docs/INSTALL b/docs/INSTALL index 9213cc3..59bdaad 100644 --- a/docs/INSTALL +++ b/docs/INSTALL @@ -38,6 +38,7 @@ Optional/Recommended The following tools are quite useful, and some of them are used in the sample scripts: +* socat (for socket communication) * dmenu (with vertical patch) * zenity * bash @@ -48,7 +49,7 @@ File locations -------------- After installing - using either method - you will find: -* /usr/bin : uzbl [and uzblctrl] +* /usr/bin : uzbl * /usr/share/uzbl/docs/ : documentation files included with uzbl. (readme, checklist, .. ) * /usr/share/uzbl/examples: sample scripts, config files and a sample data (boomarks, .. ) diff --git a/examples/config/uzbl/config b/examples/config/uzbl/config index 04e482b..efc4780 100644 --- a/examples/config/uzbl/config +++ b/examples/config/uzbl/config @@ -4,15 +4,14 @@ # keyboard behavior in this sample config is sort of vimstyle # Handlers -set history_handler = spawn $XDG_DATA_HOME/uzbl/scripts/history.sh set download_handler = spawn $XDG_DATA_HOME/uzbl/scripts/download.sh set cookie_handler = spawn $XDG_DATA_HOME/uzbl/scripts/cookies.py #set new_window = sh 'echo uri "$8" > $4' # open in same window set new_window = sh 'uzbl -u $8' # equivalent to the default behaviour set scheme_handler = spawn $XDG_DATA_HOME/uzbl/scripts/scheme.py -set load_start_handler = set status_message = <span foreground="khaki">wait</span> +set load_start_handler = chain 'set keycmd = ' 'set status_message = <span foreground="khaki">wait</span>' set load_commit_handler = set status_message = <span foreground="green">recv</span> -set load_finish_handler = set status_message = <span foreground="gold">done</span> +set load_finish_handler = chain 'set status_message = <span foreground="gold">done</span>' 'spawn $XDG_DATA_HOME/uzbl/scripts/history.sh' diff --git a/examples/data/uzbl/scripts/history.sh b/examples/data/uzbl/scripts/history.sh index d726f9c..7c83aa6 100755 --- a/examples/data/uzbl/scripts/history.sh +++ b/examples/data/uzbl/scripts/history.sh @@ -1,6 +1,5 @@ #!/bin/sh -#TODO: strip 'http://' part file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/history [ -d `dirname $file` ] || exit 1 -echo "$8 $6 $7" >> $file +echo `date +'%Y-%m-%d %H:%M:%S'`" $6 $7" >> $file diff --git a/examples/data/uzbl/scripts/load_url_from_bookmarks.sh b/examples/data/uzbl/scripts/load_url_from_bookmarks.sh index f57d7b3..1e9f9e7 100755 --- a/examples/data/uzbl/scripts/load_url_from_bookmarks.sh +++ b/examples/data/uzbl/scripts/load_url_from_bookmarks.sh @@ -17,4 +17,4 @@ else fi #[ -n "$goto" ] && echo "uri $goto" > $4 -[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto" +[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$5 diff --git a/examples/data/uzbl/scripts/load_url_from_history.sh b/examples/data/uzbl/scripts/load_url_from_history.sh index 1eaf0f2..62e02ac 100755 --- a/examples/data/uzbl/scripts/load_url_from_history.sh +++ b/examples/data/uzbl/scripts/load_url_from_history.sh @@ -21,4 +21,4 @@ else fi [ -n "$goto" ] && echo "uri $goto" > $4 -#[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto" +#[ -n "$goto" ] && echo "uri $goto" | socat - unix-connect:$5 @@ -137,7 +137,6 @@ const struct var_name_to_ptr_t { { "load_finish_handler", PTR_V_STR(uzbl.behave.load_finish_handler, 1, NULL)}, { "load_start_handler", PTR_V_STR(uzbl.behave.load_start_handler, 1, NULL)}, { "load_commit_handler", PTR_V_STR(uzbl.behave.load_commit_handler, 1, NULL)}, - { "history_handler", PTR_V_STR(uzbl.behave.history_handler, 1, NULL)}, { "download_handler", PTR_V_STR(uzbl.behave.download_handler, 1, NULL)}, { "cookie_handler", PTR_V_STR(uzbl.behave.cookie_handler, 1, cmd_cookie_handler)}, { "new_window", PTR_V_STR(uzbl.behave.new_window, 1, NULL)}, @@ -772,7 +771,6 @@ load_start_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) { (void) frame; (void) data; uzbl.gui.sbar.load_progress = 0; - clear_keycmd(); // don't need old commands to remain on new page? if (uzbl.behave.load_start_handler) run_handler(uzbl.behave.load_start_handler, ""); } @@ -799,19 +797,6 @@ destroy_cb (GtkWidget* widget, gpointer data) { gtk_main_quit (); } -void -log_history_cb () { - if (uzbl.behave.history_handler) { - time_t rawtime; - struct tm * timeinfo; - char date [80]; - time ( &rawtime ); - timeinfo = localtime ( &rawtime ); - strftime (date, 80, "\"%Y-%m-%d %H:%M:%S\"", timeinfo); - run_handler(uzbl.behave.history_handler, date); - } -} - /* VIEW funcs (little webkit wrappers) */ #define VIEWFUNC(name) void view_##name(WebKitWebView *page, GArray *argv, GString *result){(void)argv; (void)result; webkit_web_view_##name(page);} @@ -2369,7 +2354,6 @@ create_browser () { g_signal_connect (G_OBJECT (g->web_view), "load-progress-changed", G_CALLBACK (progress_change_cb), g->web_view); g_signal_connect (G_OBJECT (g->web_view), "load-committed", G_CALLBACK (load_commit_cb), g->web_view); g_signal_connect (G_OBJECT (g->web_view), "load-started", G_CALLBACK (load_start_cb), g->web_view); - g_signal_connect (G_OBJECT (g->web_view), "load-finished", G_CALLBACK (log_history_cb), g->web_view); g_signal_connect (G_OBJECT (g->web_view), "load-finished", G_CALLBACK (load_finish_cb), g->web_view); g_signal_connect (G_OBJECT (g->web_view), "hovering-over-link", G_CALLBACK (link_hover_cb), g->web_view); g_signal_connect (G_OBJECT (g->web_view), "navigation-policy-decision-requested", G_CALLBACK (navigation_decision_cb), g->web_view); @@ -2933,7 +2917,9 @@ main (int argc, char* argv[]) { gboolean verbose_override = uzbl.state.verbose; settings_init (); - set_insert_mode(FALSE); + + if (!uzbl.behave.always_insert_mode) + set_insert_mode(FALSE); if (!uzbl.behave.show_status) gtk_widget_hide(uzbl.gui.mainbar); @@ -93,7 +93,6 @@ typedef struct { gchar* title_format_short; gchar* title_format_long; gchar* status_background; - gchar* history_handler; gchar* fifo_dir; gchar* socket_dir; gchar* download_handler; @@ -270,9 +269,6 @@ void destroy_cb (GtkWidget* widget, gpointer data); void -log_history_cb (); - -void commands_hash(void); void diff --git a/uzblctrl.c b/uzblctrl.c deleted file mode 100644 index 2547bc7..0000000 --- a/uzblctrl.c +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c-basic-offset: 4; -*- */ -/* Socket code more or less completely copied from here: http://www.ecst.csuchico.edu/~beej/guide/ipc/usock.html */ - -#include <gtk/gtk.h> -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/un.h> - -static gchar* sockpath; -static gchar* command; - -static GOptionEntry entries[] = -{ - { "socket", 's', 0, G_OPTION_ARG_STRING, &sockpath, "Path to the uzbl socket", NULL }, - { "command", 'c', 0, G_OPTION_ARG_STRING, &command, "The uzbl command to execute", NULL }, - { NULL, 0, 0, 0, NULL, NULL, NULL } -}; - -int -main(int argc, char* argv[]) { - GError *error = NULL; - GOptionContext* context = g_option_context_new ("- utility for controlling and interacting with uzbl through its socket file"); /* TODO: get stuff back from uzbl */ - g_option_context_add_main_entries (context, entries, NULL); - g_option_context_add_group (context, gtk_get_option_group (TRUE)); - g_option_context_parse (context, &argc, &argv, &error); - - - if (sockpath && command) { - int s, len; - struct sockaddr_un remote; - char tmp; - - if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) == -1) { - perror ("socket"); - exit (EXIT_FAILURE); - } - - remote.sun_family = AF_UNIX; - strcpy (remote.sun_path, (char *) sockpath); - len = strlen (remote.sun_path) + sizeof (remote.sun_family); - - if (connect (s, (struct sockaddr *) &remote, len) == -1) { - perror ("connect"); - exit (EXIT_FAILURE); - } - - if ((send (s, command, strlen (command), 0) == -1) || - (send (s, "\n", 1, 0) == -1)) { - perror ("send"); - exit (EXIT_FAILURE); - } - - while ((len = recv (s, &tmp, 1, 0))) { - putchar(tmp); - if (tmp == '\n') - break; - } - - close(s); - - return 0; - } else { - fprintf(stderr, "Usage: uzblctrl -s /path/to/socket -c \"command\""); - return 1; - } -} -/* vi: set et ts=4: */ |