aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README13
-rw-r--r--examples/configs/sampleconfig1
-rw-r--r--examples/configs/sampleconfig-dev1
-rwxr-xr-xexamples/scripts/download.sh2
-rwxr-xr-xexamples/scripts/history.sh2
-rwxr-xr-xexamples/scripts/load_url_from_bookmarks.sh2
-rwxr-xr-xexamples/scripts/load_url_from_history.sh2
-rw-r--r--uzbl.c52
8 files changed, 60 insertions, 15 deletions
diff --git a/README b/README
index 02062f1..31f307a 100644
--- a/README
+++ b/README
@@ -105,18 +105,19 @@ $1 uzbl-config-file
$2 uzbl-pid
$3 uzbl-x-window-id
$4 uzbl_fifo-filename
+$5 uzbl_socket-filename
.. [ script specific ] (optional)
The script specific arguments are this:
* history:
- $5 page url
- $6 page title
- $7 date of visit (Y-m-d H:i:s localtime)
+ $6 page url
+ $7 page title
+ $8 date of visit (Y-m-d H:i:s localtime)
* add bookmark:
- $5 page url
- $6 page title
+ $6 page url
+ $7 page title
* download:
- $5 url
+ $6 url
KNOWN BUGS
- Segfaults when using zoom commands (happens when max zoom already reached?).
diff --git a/examples/configs/sampleconfig b/examples/configs/sampleconfig
index 9fba5b7..9796859 100644
--- a/examples/configs/sampleconfig
+++ b/examples/configs/sampleconfig
@@ -13,6 +13,7 @@
[behavior]
history_handler = /bin/bash /usr/share/uzbl/examples/scripts/history.sh
download_handler = /bin/bash /usr/share/uzbl/examples/scripts/download.sh
+fifo_dir = /tmp
socket_dir = /tmp
always_insert_mode = 0
modkey = Mod1
diff --git a/examples/configs/sampleconfig-dev b/examples/configs/sampleconfig-dev
index 0d8bdd3..d742147 100644
--- a/examples/configs/sampleconfig-dev
+++ b/examples/configs/sampleconfig-dev
@@ -13,6 +13,7 @@
[behavior]
history_handler = /bin/bash ./examples/scripts/history.sh
download_handler = /bin/bash ./examples/scripts/download.sh
+fifo_dir = /tmp
socket_dir = /tmp
always_insert_mode = 0
modkey = Mod1
diff --git a/examples/scripts/download.sh b/examples/scripts/download.sh
index ff3d8db..41c408e 100755
--- a/examples/scripts/download.sh
+++ b/examples/scripts/download.sh
@@ -1,2 +1,2 @@
#!/bin/bash
-wget $5
+wget $6
diff --git a/examples/scripts/history.sh b/examples/scripts/history.sh
index 03c568a..b6671fe 100755
--- a/examples/scripts/history.sh
+++ b/examples/scripts/history.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#TODO: strip 'http://' part
# you probably really want this in your $XDG_DATA_HOME (eg $HOME/.local/share/uzbl/history)
-echo "$7 $5" >> /tmp/uzbl.history
+echo "$8 $6" >> /tmp/uzbl.history
diff --git a/examples/scripts/load_url_from_bookmarks.sh b/examples/scripts/load_url_from_bookmarks.sh
index d13b990..2a893bf 100755
--- a/examples/scripts/load_url_from_bookmarks.sh
+++ b/examples/scripts/load_url_from_bookmarks.sh
@@ -10,4 +10,4 @@ fi
goto=`awk '{print $1}' $file | dmenu -i` #NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes.
#[ -n "$goto" ] && echo "uri $goto" > $4
-[ -n "$goto" ] && uzblctrl -s $4 -c "uri $goto"
+[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto"
diff --git a/examples/scripts/load_url_from_history.sh b/examples/scripts/load_url_from_history.sh
index cab4529..81a220a 100755
--- a/examples/scripts/load_url_from_history.sh
+++ b/examples/scripts/load_url_from_history.sh
@@ -4,4 +4,4 @@ history_file=/tmp/uzbl.history
goto=`awk '{print $3}' $history_file | sort | uniq | dmenu -i`
#[ -n "$goto" ] && echo "uri $goto" > $4
-[ -n "$goto" ] && uzblctrl -s $4 -c "uri $goto"
+[ -n "$goto" ] && uzblctrl -s $5 -c "uri $goto"
diff --git a/uzbl.c b/uzbl.c
index 2eeb9e3..75616af 100644
--- a/uzbl.c
+++ b/uzbl.c
@@ -45,6 +45,7 @@
#include <errno.h>
#include <string.h>
#include <sys/types.h>
+#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -57,6 +58,7 @@ static gchar* main_title;
static gchar selected_url[500] = "\0";
static gint load_progress;
static Window xwin = 0;
+static char fifo_path[64];
static char socket_path[108];
/* state variables (initial values coming from command line arguments but may be changed later) */
@@ -67,6 +69,7 @@ static gboolean verbose = FALSE;
/* settings from config: group behaviour */
static gchar* history_handler = NULL;
+static gchar* fifo_dir = NULL;
static gchar* socket_dir = NULL;
static gchar* download_handler = NULL;
static gboolean always_insert_mode = FALSE;
@@ -345,10 +348,10 @@ close_uzbl (WebKitWebView * web_view) {
// make sure to put '' around args, so that if there is whitespace we can still keep arguments together.
static gboolean
run_command(const char *command, const char *args) {
- //command <uzbl conf> <uzbl pid> <uzbl win id> <uzbl socket file> [args]
+ //command <uzbl conf> <uzbl pid> <uzbl win id> <uzbl fifo file> <uzbl socket file> [args]
GString* to_execute = g_string_new ("");
gboolean result;
- g_string_printf (to_execute, "%s '%s' '%i' '%i' '%s'", command, config_file, (int) getpid() , (int) xwin, socket_path);
+ g_string_printf (to_execute, "%s '%s' '%i' '%i' '%s' '%s'", command, config_file, (int) getpid() , (int) xwin, fifo_path, socket_path);
if(args) {
g_string_append_printf (to_execute, " %s", args);
}
@@ -388,11 +391,45 @@ parse_command(const char *cmd) {
}
static void
+control_fifo(GIOChannel *fd) {
+ gchar *ctl_line;
+ gsize ctl_line_length, term_pos;
+
+ if(!fd)
+ return;
+
+ g_io_channel_read_line(fd, &ctl_line, &ctl_line_length, &term_pos, NULL); //TODO: support partial writes
+ ctl_line[term_pos] ='\0';
+ parse_command(ctl_line);
+
+ return;
+}
+
+static void
+create_fifo() {
+ GIOChannel *chan = NULL;
+
+ if (fifo_dir) {
+ sprintf (fifo_path, "%s/uzbl_fifo_%d", fifo_dir, (int) xwin);
+ } else {
+ sprintf (fifo_path, "/tmp/uzbl_fifo_%d", (int) xwin);
+ }
+ printf ("Control fifo opened in %s\n", fifo_path);
+ if (mkfifo (fifo_path, 0666) == -1) {
+ printf ("Possible error creating fifo\n");
+ }
+
+ if( (chan = g_io_channel_new_file((gchar *) fifo_path, "r+", NULL)) )
+ g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, chan);
+ return;
+}
+
+static void
*control_socket() {
if (socket_dir) {
- sprintf (socket_path, "%s/uzbl_%d", socket_dir, (int) xwin);
+ sprintf (socket_path, "%s/uzbl_socket_%d", socket_dir, (int) xwin);
} else {
- sprintf (socket_path, "/tmp/uzbl_%d", (int) xwin);
+ sprintf (socket_path, "/tmp/uzbl_socket_%d", (int) xwin);
}
int sock, clientsock, len;
@@ -638,12 +675,15 @@ settings_init () {
keyse = g_key_file_get_keys (config, "bindings_external", NULL, NULL);
status_top = g_key_file_get_boolean (config, "behavior", "status_top", NULL);
home_page = g_key_file_get_value (config, "behavior", "home_page", NULL);
+ if (! fifo_dir)
+ fifo_dir = g_key_file_get_value (config, "behavior", "fifo_dir", NULL);
if (! socket_dir)
- socket_dir = g_key_file_get_value (config, "behavior", "socket_dir", NULL);
+ socket_dir = g_key_file_get_value (config, "behavior", "socket_dir", NULL);
}
printf ("History handler: %s\n", (history_handler ? history_handler : "disabled"));
printf ("Download manager: %s\n", (download_handler ? download_handler : "disabled"));
+ printf ("Fifo directory: %s\n", (fifo_dir ? fifo_dir : "/tmp"));
printf ("Socket directory: %s\n", (socket_dir ? socket_dir : "/tmp"));
printf ("Always insert mode: %s\n", (always_insert_mode ? "TRUE" : "FALSE"));
printf ("Show status: %s\n", (show_status ? "TRUE" : "FALSE"));
@@ -740,10 +780,12 @@ main (int argc, char* argv[]) {
gtk_widget_hide(mainbar);
setup_threading ();
+ create_fifo ();
gtk_main ();
unlink (socket_path);
+ unlink (fifo_path);
return 0;
}