aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--AUTHORS1
-rw-r--r--Makefile3
-rw-r--r--README38
-rw-r--r--docs/COMMUNITY10
-rw-r--r--examples/config/config44
-rwxr-xr-xexamples/data/scripts/download.sh2
-rwxr-xr-xexamples/data/scripts/follow.sh2
-rwxr-xr-xexamples/data/scripts/formfiller.sh5
-rwxr-xr-xexamples/data/scripts/go_input.sh19
-rwxr-xr-xexamples/data/scripts/history.sh2
-rwxr-xr-xexamples/data/scripts/insert_bookmark.sh5
-rwxr-xr-xexamples/data/scripts/load_url_from_bookmarks.sh1
-rwxr-xr-xexamples/data/scripts/load_url_from_history.sh3
-rwxr-xr-xexamples/data/scripts/session.sh33
-rwxr-xr-xexamples/data/scripts/userscript.sh16
-rwxr-xr-xexamples/data/scripts/userscripts.sh2
-rw-r--r--examples/data/scripts/util/dmenu.sh2
-rw-r--r--examples/data/scripts/util/uzbl-args.sh17
-rw-r--r--examples/data/scripts/util/uzbl-window.sh6
-rwxr-xr-xexamples/data/scripts/uzbl-tabbed5
-rw-r--r--src/callbacks.c2
-rw-r--r--src/events.c13
-rwxr-xr-xsrc/uzbl-browser2
-rw-r--r--src/uzbl-core.c59
-rw-r--r--src/uzbl-core.h3
26 files changed, 110 insertions, 186 deletions
diff --git a/.gitignore b/.gitignore
index 078164f..2ddbb60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ uzbl-core
*.pyc
*~
tags
+uzbl-cookie-manager
diff --git a/AUTHORS b/AUTHORS
index 830df44..848f467 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -51,6 +51,7 @@ In alphabetical order:
James S Wheaton (uranther) - zoom level, test framework
Jan Kolkmeier (jouz) - scrolling, link following
Jason Woofenden (JasonWoof) - geometry=maximized, link following
+ Jochen Sprickerhof - session.sh enhancements
Lars-Dominik Braun (PromyLOPh) - added ability to enable/disable the webkit page cache
Laurence Withers (lwithers) - talk_to_socket
Luca Bruno <lucab@debian.org> - bashims fixes
diff --git a/Makefile b/Makefile
index 04f35d0..e4d1b42 100644
--- a/Makefile
+++ b/Makefile
@@ -119,9 +119,6 @@ install-uzbl-core: all install-dirs
install -m644 AUTHORS $(DOCDIR)/
cp -r examples $(INSTALLDIR)/share/uzbl/
chmod 755 $(INSTALLDIR)/share/uzbl/examples/data/scripts/*
- mv $(INSTALLDIR)/share/uzbl/examples/config/config $(INSTALLDIR)/share/uzbl/examples/config/config.bak
- sed 's#^set prefix.*=.*#set prefix = $(RUN_PREFIX)#' < $(INSTALLDIR)/share/uzbl/examples/config/config.bak > $(INSTALLDIR)/share/uzbl/examples/config/config
- rm $(INSTALLDIR)/share/uzbl/examples/config/config.bak
install -m755 uzbl-core $(INSTALLDIR)/bin/uzbl-core
install-uzbl-browser: uzbl-cookie-manager install-dirs
diff --git a/README b/README
index 6dddb35..331b040 100644
--- a/README
+++ b/README
@@ -480,23 +480,22 @@ You can use external scripts with Uzbl the following ways:
Have a look at the sample configs and scripts!
-Handler scripts that are called by `uzbl` are passed the following arguments:
+Scripts called by `uzbl` (with `spawn`, `sync_spawn`, `sh` or `sync_sh`) have
+access to the following environment variables:
-* `$1 config`: The configuration file loaded by this `uzbl` instance.
-* `$2 pid`: The process ID of this `uzbl` instance.
-* `$3 x_id`: The X Windows ID of the process.
-* `$4 fifo`: The filename of the FIFO being used, if any.
-* `$5 socket`: The filename of the Unix socket being used, if any.
-* `$6 uri`: The URI of the current page.
-* `$7 title`: The current page title.
-* `.. [ script specific ] (optional)`
+* `$UZBL_CONFIG`: The configuration file loaded by this `uzbl` instance.
+* `$UZBL_PID`: The process ID of this `uzbl` instance.
+* `$UZBL_XID`: The X Windows ID of the process.
+* `$UZBL_FIFO`: The filename of the FIFO being used, if any.
+* `$UZBL_SOCKET`: The filename of the Unix socket being used, if any.
+* `$UZBL_URI`: The URI of the current page.
+* `$UZBL_TITLE`: The current page title.
-The script specific arguments are:
+These variables are also available as positional arguments `$1` through `$7`,
+but this is deprecated and will be removed.
-* download
-
- - `$8 url`: The URL of the item to be downloaded.
- - `$9 proxy`: (optional) The URL of an HTTP proxy.
+Handler scripts (`cookie_handler`, `scheme_handler` and
+`authentication_handler`) are called with special arguments:
* cookie handler
@@ -514,13 +513,10 @@ The script specific arguments are:
* authentication handler:
- $8 authentication zone unique identifier
- $9 domain part of URL that requests authentication
- $10 authentication realm
- $11 FALSE if this is the first attempt to authenticate, TRUE otherwise
-
-Custom, userdefined scripts (`spawn foo bar`) get first the arguments as
-specified in the config and then the above 7 are added at the end.
+ - `$8`: authentication zone unique identifier
+ - `$9`: domain part of URL that requests authentication
+ - `$10`: authentication realm
+ - `$11`: FALSE if this is the first attempt to authenticate, TRUE otherwise
### Formfiller.sh
diff --git a/docs/COMMUNITY b/docs/COMMUNITY
index 2817ee9..cbf3b48 100644
--- a/docs/COMMUNITY
+++ b/docs/COMMUNITY
@@ -4,12 +4,12 @@ COMMUNITY
### Mailing list
* Address: [uzbl-dev@lists.uzbl.org](mailto:uzbl-dev@lists.uzbl.org)
-* [Page](http://lists.uzbl.org/listinfo.cgi/uzbl-dev-uzbl.org)
-* [Archives](http://lists.uzbl.org/pipermail/uzbl-dev-uzbl.org/)
+* [Page](http://lists.uzbl.org/listinfo/uzbl-dev)
+* [Archives](http://lists.uzbl.org/pipermail/uzbl-dev/)
### IRC
-* `#uzbl` on irc.freenode.net
+* `#uzbl` on irc.freenode.net ([webchat](http://webchat.freenode.net/?channels=uzbl))
* [Archive](http://www.uzbl.org/irc-log)
### Website
@@ -23,10 +23,6 @@ COMMUNITY
### Code repositories
* [github.com/Dieterbe/uzbl](http://github.com/Dieterbe/uzbl/)
-* [github.com/anydot/uzbl](http://github.com/anydot/uzbl/)
-* [github.com/Barrucadu/uzbl](http://github.com/Barrucadu/uzbl/)
-* [github.com/dusanx/uzbl](http://github.com/dusanx/uzbl/)
-* [github.com/robm/uzbl](http://github.com/robm/uzbl/)
There are more contributors who have forks. See:
diff --git a/examples/config/config b/examples/config/config
index a8547d2..5d7073f 100644
--- a/examples/config/config
+++ b/examples/config/config
@@ -3,8 +3,10 @@
# === Core settings ==========================================================
-# Install location prefix.
-set prefix = /usr/local
+# common directory locations
+set prefix = @(echo $PREFIX)@
+set data_home = @(echo $XDG_DATA_HOME)@
+set cache_home = @(echo $XDG_CACHE_HOME)@
# Interface paths.
set fifo_dir = /tmp
@@ -34,13 +36,13 @@ set set_mode = set mode =
set set_status = set status_message =
# Spawn path shortcuts. In spawn the first dir+path match is used in "dir1:dir2:dir3:executable"
-set scripts_dir = $XDG_DATA_HOME/uzbl:@prefix/share/uzbl/examples/data:scripts
+set scripts_dir = @data_home/uzbl:@prefix/share/uzbl/examples/data:scripts
# === Hardcoded handlers =====================================================
# These handlers can't be moved to the new event system yet as we don't
# support events that can wait for a response from a script.
-set cookie_handler = talk_to_socket $XDG_CACHE_HOME/uzbl/cookie_daemon_socket
+set cookie_handler = talk_to_socket @cache_home/uzbl/cookie_daemon_socket
set scheme_handler = sync_spawn @scripts_dir/scheme.py
set authentication_handler = sync_spawn @scripts_dir/auth.py
set download_handler = sync_spawn @scripts_dir/download.sh
@@ -184,7 +186,7 @@ set ebind = @mode_bind global,-insert
# --- Mouse bindings ---------------------------------------------------------
# Middle click open in new window
-@bind <Button2> = sh 'if [ "$8" ]; then uzbl-browser -u "$8"; else echo "uri $(xclip -o | sed s/\\\@/%40/g)" > $4; fi' \@SELECTED_URI
+@bind <Button2> = sh 'if [ "$8" ]; then uzbl-browser -u "$8"; else echo "uri $(xclip -o | sed s/\\\@/%40/g)" > "$UZBL_FIFO"; fi' \@SELECTED_URI
# --- Keyboard bindings ------------------------------------------------------
@@ -248,14 +250,14 @@ set ebind = @mode_bind global,-insert
# Exit binding
@cbind ZZ = exit
# Dump config to stdout
-@cbind !dump = sh "echo dump_config > $4"
+@cbind !dump = sh 'echo dump_config > "$UZBL_FIFO"'
# Reload all variables in the config
-@cbind !reload = sh "sed '/^# === Post-load misc commands/,$d' $1 | grep '^set ' > $4"
+@cbind !reload = sh "sed '/^# === Post-load misc commands/,$d' \"$UZBL_CONFIG\" | grep '^set ' > \"$UZBL_FIFO\""
# Use socat to directly inject commands into uzbl-core and view events
# raised by uzbl-core:
-@cbind <Ctrl><Alt>t = sh 'xterm -e "socat unix-connect:$5 -"'
-#@cbind <Ctrl><Alt>t = sh 'urxvt -e socat unix-connect:$5 -'
+@cbind <Ctrl><Alt>t = sh "xterm -e 'socat unix-connect:\"$UZBL_SOCKET\" -'"
+#@cbind <Ctrl><Alt>t = sh "urxvt -e 'socat unix-connect:\"$UZBL_SOCKET\" -'"
# Uri opening prompts
@cbind o<uri:>_ = uri %s
@@ -270,24 +272,24 @@ set ebind = @mode_bind global,-insert
@cbind gh = uri http://www.uzbl.org
# Yanking & pasting binds
-@cbind yu = sh 'echo -n $6 | xclip'
+@cbind yu = sh 'echo -n "$UZBL_URI" | xclip'
@cbind yU = sh 'echo -n $8 | xclip' \@SELECTED_URI
-@cbind yy = sh 'echo -n $7 | xclip'
+@cbind yy = sh 'echo -n "$UZBL_TITLE" | xclip'
@cbind yY = sh 'echo -n $8 | xclip' \@SELECTED_URI
# Clone current window
-@cbind c = sh 'uzbl-browser -u $6'
+@cbind c = sh 'uzbl-browser -u "$UZBL_URI"'
# Go the page from primary selection
-@cbind p = sh 'echo "uri `xclip -selection primary -o | sed s/\\\@/%40/g`" > $4'
+@cbind p = sh 'echo "uri `xclip -selection primary -o | sed s/\\\@/%40/g`" > "$UZBL_FIFO"'
# Go to the page in clipboard
-@cbind P = sh 'echo "uri `xclip -selection clipboard -o | sed s/\\\@/%40/g`" > $4'
+@cbind P = sh 'echo "uri `xclip -selection clipboard -o | sed s/\\\@/%40/g`" > "$UZBL_FIFO"'
# Start a new uzbl instance from the page in primary selection
-@cbind 'p = sh 'exec uzbl-browser --uri $(xclip -o)'
+@cbind 'p = sh 'exec uzbl-browser --uri "$(xclip -o)"'
# paste primary selection into keycmd at the cursor position
-@bind <Shift-Insert> = sh 'echo "event INJECT_KEYCMD `xclip -o | sed s/\\\@/%40/g`" > $4'
+@bind <Shift-Insert> = sh 'echo "event INJECT_KEYCMD `xclip -o | sed s/\\\@/%40/g`" > "$UZBL_FIFO"'
# Bookmark inserting binds
-@cbind <Ctrl>b<tags:>_ = sh 'echo `printf "$6 %s"` >> $XDG_DATA_HOME/uzbl/bookmarks'
+@cbind <Ctrl>b<tags:>_ = sh 'echo `printf "$UZBL_URI %s"` >> "$XDG_DATA_HOME"/uzbl/bookmarks'
# Or use a script to insert a bookmark.
@cbind B = spawn @scripts_dir/insert_bookmark.sh
@@ -322,12 +324,12 @@ set formfiller = spawn @scripts_dir/formfiller.sh
@cbind gN = event NEW_TAB_NEXT
@cbind go<uri:>_ = event NEW_TAB %s
@cbind gO<uri:>_ = event NEW_TAB_NEXT %s
-@cbind gy = sh 'echo "event NEW_TAB `xclip -selection primary -o | sed s/\\\@/%40/g`" > $4'
-@cbind gY = sh 'echo "event NEW_TAB_NEXT `xclip -selection primary -o | sed s/\\\@/%40/g`" > $4'
+@cbind gy = sh 'echo "event NEW_TAB `xclip -selection primary -o | sed s/\\\@/%40/g`" > "$UZBL_FIFO"'
+@cbind gY = sh 'echo "event NEW_TAB_NEXT `xclip -selection primary -o | sed s/\\\@/%40/g`" > "$UZBL_FIFO"'
# Clone current tab
-@cbind gd = sh 'echo "event NEW_TAB $6" > $4'
-@cbind gD = sh 'echo "event NEW_TAB_NEXT $6" > $4'
+@cbind gd = sh 'echo "event NEW_TAB $UZBL_URI" > "$UZBL_FIFO"'
+@cbind gD = sh 'echo "event NEW_TAB_NEXT $UZBL_URI" > "$UZBL_FIFO"'
# Closing / resting
@cbind gC = exit
diff --git a/examples/data/scripts/download.sh b/examples/data/scripts/download.sh
index c6d95f7..df7a571 100755
--- a/examples/data/scripts/download.sh
+++ b/examples/data/scripts/download.sh
@@ -6,7 +6,7 @@
# that path.
# if nothing is printed to stdout, the download will be cancelled.
-. $UZBL_UTIL_DIR/uzbl-args.sh
+shift 7
. $UZBL_UTIL_DIR/uzbl-dir.sh
# the URL that is being downloaded
diff --git a/examples/data/scripts/follow.sh b/examples/data/scripts/follow.sh
index c8ded84..2d666a2 100755
--- a/examples/data/scripts/follow.sh
+++ b/examples/data/scripts/follow.sh
@@ -3,7 +3,7 @@
# This script is just a wrapper around follow.js that lets us change uzbl's mode
# after a link is selected.
-. "$UZBL_UTIL_DIR"/uzbl-args.sh
+shift 7
# if socat is installed then we can change Uzbl's input mode once a link is
# selected; otherwise we just select a link.
diff --git a/examples/data/scripts/formfiller.sh b/examples/data/scripts/formfiller.sh
index b2e61ec..6e04573 100755
--- a/examples/data/scripts/formfiller.sh
+++ b/examples/data/scripts/formfiller.sh
@@ -45,7 +45,6 @@ DMENU_OPTIONS="vertical resize"
. $UZBL_UTIL_DIR/dmenu.sh
. $UZBL_UTIL_DIR/editor.sh
-. $UZBL_UTIL_DIR/uzbl-args.sh
. $UZBL_UTIL_DIR/uzbl-dir.sh
RAND=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -c 1-5)
@@ -54,9 +53,11 @@ MODELINE="> vim:ft=formfiller"
[ -d "$(dirname $UZBL_FORMS_DIR)" ] || exit 1
[ -d $UZBL_FORMS_DIR ] || mkdir $UZBL_FORMS_DIR || exit 1
+shift 7
+
action=$1
-domain=$(echo $UZBL_URL | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/')
+domain=$(echo $UZBL_URI | sed 's/\(http\|https\):\/\/\([^\/]\+\)\/.*/\2/')
if [ "$action" != 'edit' -a "$action" != 'new' -a "$action" != 'load' -a "$action" != 'add' -a "$action" != 'once' ]; then
action="new"
diff --git a/examples/data/scripts/go_input.sh b/examples/data/scripts/go_input.sh
index c873dd8..ace0e79 100755
--- a/examples/data/scripts/go_input.sh
+++ b/examples/data/scripts/go_input.sh
@@ -1,20 +1,5 @@
#!/bin/sh
-config=$1;
-shift
-pid=$1;
-shift
-xid=$1;
-shift
-fifo=$1;
-shift
-socket=$1;
-shift
-url=$1;
-shift
-title=$1;
-shift
-
-case $(echo 'script @scripts_dir/go_input.js' | socat - unix-connect:$socket) in
- *XXXEMIT_FORM_ACTIVEXXX*) echo 'event FORM_ACTIVE' | socat - unix-connect:$socket ;;
+case $(echo 'script @scripts_dir/go_input.js' | socat - unix-connect:"$UZBL_SOCKET") in
+ *XXXEMIT_FORM_ACTIVEXXX*) echo 'event FORM_ACTIVE' > "$UZBL_FIFO" ;;
esac
diff --git a/examples/data/scripts/history.sh b/examples/data/scripts/history.sh
index 0561fe9..266d65d 100755
--- a/examples/data/scripts/history.sh
+++ b/examples/data/scripts/history.sh
@@ -4,4 +4,4 @@
[ -w "$UZBL_HISTORY_FILE" ] || [ ! -a "$UZBL_HISTORY_FILE" ] || exit 1
-echo $(date +'%Y-%m-%d %H:%M:%S')" $6 $7" >> $UZBL_HISTORY_FILE
+echo $(date +'%Y-%m-%d %H:%M:%S')" $UZBL_URI $UZBL_TITLE" >> $UZBL_HISTORY_FILE
diff --git a/examples/data/scripts/insert_bookmark.sh b/examples/data/scripts/insert_bookmark.sh
index 24f7241..f67e67a 100755
--- a/examples/data/scripts/insert_bookmark.sh
+++ b/examples/data/scripts/insert_bookmark.sh
@@ -1,6 +1,5 @@
#!/bin/sh
-. "$UZBL_UTIL_DIR"/uzbl-args.sh
. "$UZBL_UTIL_DIR"/uzbl-dir.sh
[ -d "$UZBL_DATA_DIR" ] || exit 1
@@ -8,9 +7,9 @@
which zenity >/dev/null 2>&1 || exit 2
-tags=$(zenity --entry --text="Enter space-separated tags for bookmark $UZBL_URL:")
+tags=$(zenity --entry --text="Enter space-separated tags for bookmark $UZBL_URI:")
exitstatus=$?
[ $exitstatus -eq 0 ] || exit $exitstatus
# TODO: check if already exists, if so, and tags are different: ask if you want to replace tags
-echo "$UZBL_URL $tags" >> "$UZBL_BOOKMARKS_FILE"
+echo "$UZBL_URI $tags" >> "$UZBL_BOOKMARKS_FILE"
diff --git a/examples/data/scripts/load_url_from_bookmarks.sh b/examples/data/scripts/load_url_from_bookmarks.sh
index 9346526..a5d9586 100755
--- a/examples/data/scripts/load_url_from_bookmarks.sh
+++ b/examples/data/scripts/load_url_from_bookmarks.sh
@@ -6,7 +6,6 @@ DMENU_SCHEME="bookmarks"
DMENU_OPTIONS="xmms vertical resize"
. "$UZBL_UTIL_DIR"/dmenu.sh
-. "$UZBL_UTIL_DIR"/uzbl-args.sh
. "$UZBL_UTIL_DIR"/uzbl-dir.sh
[ -r "$UZBL_BOOKMARKS_FILE" ] || exit 1
diff --git a/examples/data/scripts/load_url_from_history.sh b/examples/data/scripts/load_url_from_history.sh
index 4499e7f..59ad492 100755
--- a/examples/data/scripts/load_url_from_history.sh
+++ b/examples/data/scripts/load_url_from_history.sh
@@ -4,7 +4,6 @@ DMENU_SCHEME="history"
DMENU_OPTIONS="xmms vertical resize"
. "$UZBL_UTIL_DIR"/dmenu.sh
-. "$UZBL_UTIL_DIR"/uzbl-args.sh
. "$UZBL_UTIL_DIR"/uzbl-dir.sh
[ -r "$UZBL_HISTORY_FILE" ] || exit 1
@@ -13,7 +12,7 @@ DMENU_OPTIONS="xmms vertical resize"
# goto=$(awk '{print $3}' $history_file | sort -u | dmenu -i)
if [ -z "$DMENU_HAS_VERTICAL" ]; then
current=$(tail -n 1 "$UZBL_HISTORY_FILE" | awk '{print $3}');
- goto=$((echo $current; awk '{print $3}' "$UZBL_HISTORY_FILE" | grep -v "^$current\$" | sort -u) | $DMENU)
+ goto=$( (echo $current; awk '{print $3}' "$UZBL_HISTORY_FILE" | grep -v "^$current\$" | sort -u) | $DMENU)
else
# choose an item in reverse order, showing also the date and page titles
# pick the last field from the first 3 fields. this way you can pick a url (prefixed with date & time) or type just a new url.
diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh
index 203cd52..36e0c19 100755
--- a/examples/data/scripts/session.sh
+++ b/examples/data/scripts/session.sh
@@ -1,14 +1,17 @@
#!/bin/sh
#
# Very simple session manager for uzbl-browser.
-# To use, add a line like 'bind quit = spawn @scripts_dir/session.sh endsession'
-# to your config.
-# To restore the session, run this script with the argument "launch". An
-# instance of uzbl-browser will be launched for each stored url.
+# To use, add a line like 'bind quit = spawn @scripts_dir/session.sh' to your
+# config. This binding will exit every instance of uzbl and store the URLs they
+# had open in $UZBL_SESSION_FILE.
#
-# When called with "endsession" as the argument, it will backup
-# $UZBL_SESSION_FILE, look for fifos in $UZBL_FIFO_DIR and instruct each of them
-# to store its current url in $UZBL_SESSION_FILE and terminate.
+# When a session file exists this script can be run with no arguments (or the
+# argument "launch") to start an instance of uzbl-browser for every stored url.
+#
+# If no session file exists (or if called with "endsession" as the first
+# argument), this script looks for instances of uzbl that have fifos in
+# $UZBL_FIFO_DIR and instructs each of them to store its current url in
+# $UZBL_SESSION_FILE and terminate.
#
# "endinstance" is used internally and doesn't need to be called manually.
@@ -29,12 +32,17 @@ UZBL="uzbl-browser -c $UZBL_CONFIG_FILE" # add custom flags and whatever here.
if [ $# -gt 1 ]; then
# this script is being run from uzbl, rather than standalone
- . "$UZBL_UTIL_DIR"/uzbl-args.sh
+ # discard the uzbl arguments
+ shift 7
fi
-scriptfile=$0 # this script
+scriptfile=$(readlink -f $0) # this script
act="$1"
+if [ -z "$act" ]; then
+ [ -f "$UZBL_SESSION_FILE" ] && act="launch" || act="endsession"
+fi
+
case $act in
"launch" )
urls=$(cat "$UZBL_SESSION_FILE")
@@ -43,8 +51,8 @@ case $act in
else
for url in $urls; do
$UZBL --uri "$url" &
- disown
done
+ mv "$UZBL_SESSION_FILE" "$UZBL_SESSION_FILE~"
fi
;;
@@ -53,18 +61,17 @@ case $act in
echo "session manager: endinstance must be called from uzbl"
exit 1
fi
- [ "$UZBL_URL" != "(null)" ] && echo "$UZBL_URL" >> "$UZBL_SESSION_FILE"
+ [ "$UZBL_URI" != "(null)" ] && echo "$UZBL_URI" >> "$UZBL_SESSION_FILE"
echo exit > "$UZBL_FIFO"
;;
"endsession" )
- mv "$UZBL_SESSION_FILE" "$UZBL_SESSION_FILE~"
for fifo in "$UZBL_FIFO_DIR"/uzbl_fifo_*; do
if [ "$fifo" != "$UZBL_FIFO" ]; then
echo "spawn $scriptfile endinstance" > "$fifo"
fi
done
- echo "spawn $scriptfile endinstance" > "$UZBL_FIFO"
+ [ -z "$UZBL_FIFO" ] || echo "spawn $scriptfile endinstance" > "$UZBL_FIFO"
;;
* )
diff --git a/examples/data/scripts/userscript.sh b/examples/data/scripts/userscript.sh
index 33a24ae..fd95fdc 100755
--- a/examples/data/scripts/userscript.sh
+++ b/examples/data/scripts/userscript.sh
@@ -2,13 +2,11 @@
if [ $# = "3" ]
then
- fifo="$1"
- url="$2"
- SCRIPT="$3"
+ UZBL_FIFO=$1
+ UZBL_URI=$2
+ SCRIPT=$3
else
- fifo="$4"
- url="$6"
- SCRIPT="$8"
+ SCRIPT=$8
fi
# Extract metadata chunk
@@ -18,7 +16,7 @@ SHOULD_RUN=false # Assume this script will not be included
for INCLUDE in `echo "$META" | grep "^\s*\/\/\s*@include"`; do
# Munge into grep pattern
INCLUDE="`echo "$INCLUDE" | sed -e 's/^\s*\/\/\s*@include\s*//' -e 's/\./\\\\./g' -e 's/\*/.*/g' -e 's/[\r\n]//g'`"
- if echo "$url" | grep -x "$INCLUDE"; then
+ if echo "$UZBL_URI" | grep -x "$INCLUDE"; then
SHOULD_RUN=true
break
fi
@@ -28,7 +26,7 @@ done
for EXCLUDE in `echo "$META" | grep "^\s*\/\/\s*@exclude"`; do
# Munge into grep pattern
EXCLUDE="`echo "$EXCLUDE" | sed -e 's/^\s*\/\/\s*@exclude\s*//' -e 's/\./\\\\./g' -e 's/\*/.*/g' -e 's/[\r\n]//g'`"
- if echo "$url" | grep -x "$EXCLUDE"; then
+ if echo "$UZBL_URI" | grep -x "$EXCLUDE"; then
SHOULD_RUN=false
break
fi
@@ -36,5 +34,5 @@ done
# Run the script
if [ $SHOULD_RUN = true ]; then
- echo "script '$SCRIPT'" > "$fifo"
+ echo "script '$SCRIPT'" > "$UZBL_FIFO"
fi
diff --git a/examples/data/scripts/userscripts.sh b/examples/data/scripts/userscripts.sh
index 8896224..4f76c90 100755
--- a/examples/data/scripts/userscripts.sh
+++ b/examples/data/scripts/userscripts.sh
@@ -4,5 +4,5 @@ scripts_dir="$XDG_DATA_HOME/uzbl/userscripts"
for SCRIPT in $(grep -rlx "\s*//\s*==UserScript==\s*" "$scripts_dir")
do
- $XDG_DATA_HOME/uzbl/scripts/userscript.sh "$4" "$6" "$SCRIPT"
+ $XDG_DATA_HOME/uzbl/scripts/userscript.sh "$UZBL_FIFO" "$UZBL_URI" "$SCRIPT"
done
diff --git a/examples/data/scripts/util/dmenu.sh b/examples/data/scripts/util/dmenu.sh
index f789178..da61cae 100644
--- a/examples/data/scripts/util/dmenu.sh
+++ b/examples/data/scripts/util/dmenu.sh
@@ -67,7 +67,7 @@ if dmenu --help 2>&1 | grep -q '\[-xs\]'; then
fi
# Detect the vertical patch
-if dmenu --help 2>&1 | grep -q '\[-l <lines>\]'; then
+if dmenu --help 2>&1 | grep -q '\[-l <\?lines>\?\]'; then
# Default to 10 lines
if [ -z "$DMENU_LINES" ]; then
DMENU_LINES=10
diff --git a/examples/data/scripts/util/uzbl-args.sh b/examples/data/scripts/util/uzbl-args.sh
deleted file mode 100644
index 7a3dbe5..0000000
--- a/examples/data/scripts/util/uzbl-args.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-# Arguments from uzbl
-
-UZBL_CONFIG=$1
-shift
-UZBL_PID=$1
-shift
-UZBL_XID=$1
-shift
-UZBL_FIFO=$1
-shift
-UZBL_SOCKET=$1
-shift
-UZBL_URL=$1
-shift
-UZBL_TITLE=$1
-shift
diff --git a/examples/data/scripts/util/uzbl-window.sh b/examples/data/scripts/util/uzbl-window.sh
index b2771e4..a7e92eb 100644
--- a/examples/data/scripts/util/uzbl-window.sh
+++ b/examples/data/scripts/util/uzbl-window.sh
@@ -1,12 +1,6 @@
#!/bin/sh
# uzbl window detection
-if [ -z "$UZBL_XID" ]; then
- echo "Error: UZBL_XID not set"
- echo "Please source uzbl-args.sh first"
- exit 1
-fi
-
UZBL_WIN_POS=$(xwininfo -id $UZBL_XID | \
sed -ne 's/Corners:[ ]*[+-]\([0-9]*\)[+-]\([0-9]*\).*$/\1 \2/p')
UZBL_WIN_SIZE=$(xwininfo -id $UZBL_XID | \
diff --git a/examples/data/scripts/uzbl-tabbed b/examples/data/scripts/uzbl-tabbed
index 9e5d715..0086c04 100755
--- a/examples/data/scripts/uzbl-tabbed
+++ b/examples/data/scripts/uzbl-tabbed
@@ -471,8 +471,9 @@ class UzblInstance:
elif var == "gtk_tab_pos":
self.parent.update_gtk_tab_pos()
elif var == "status_background":
- col = gtk.gdk.color_parse(config['status_background'])
- self.parent.ebox.modify_bg(gtk.STATE_NORMAL, col)
+ if config['status_background'].strip():
+ col = gtk.gdk.color_parse(config['status_background'])
+ self.parent.ebox.modify_bg(gtk.STATE_NORMAL, col)
elif var == "tab_titles" or var == "tab_indexes":
for tab in self.parent.notebook:
self.parent.tabs[tab].title_changed(True)
diff --git a/src/callbacks.c b/src/callbacks.c
index 803428d..bcbac00 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -411,6 +411,7 @@ title_change_cb (WebKitWebView* web_view, GParamSpec param_spec) {
uzbl.gui.main_title = title ? g_strdup (title) : g_strdup ("(no title)");
update_title();
send_event(TITLE_CHANGED, uzbl.gui.main_title, NULL);
+ g_setenv("UZBL_TITLE", uzbl.gui.main_title, TRUE);
}
void
@@ -436,6 +437,7 @@ load_status_change_cb (WebKitWebView* web_view, GParamSpec param_spec) {
g_free (uzbl.state.uri);
GString* newuri = g_string_new (webkit_web_frame_get_uri (frame));
uzbl.state.uri = g_string_free (newuri, FALSE);
+ g_setenv("UZBL_URI", uzbl.state.uri, TRUE);
send_event(LOAD_COMMIT, webkit_web_frame_get_uri (frame), NULL);
break;
diff --git a/src/events.c b/src/events.c
index 55775a8..b02cb89 100644
--- a/src/events.c
+++ b/src/events.c
@@ -137,24 +137,16 @@ send_event_stdout(GString *msg) {
void
send_event(int type, const gchar *details, const gchar *custom_event) {
GString *event_message = g_string_new("");
- gchar *buf, *p_val = NULL;
-
- /* expand shell vars */
- if(details) {
- buf = g_strdup(details);
- p_val = parseenv(buf ? g_strchug(buf) : " ");
- g_free(buf);
- }
/* check for custom events */
if(custom_event) {
g_string_printf(event_message, "EVENT [%s] %s %s\n",
- uzbl.state.instance_name, custom_event, p_val);
+ uzbl.state.instance_name, custom_event, details);
}
/* check wether we support the internal event */
else if(type < LAST_EVENT) {
g_string_printf(event_message, "EVENT [%s] %s %s\n",
- uzbl.state.instance_name, event_table[type], p_val);
+ uzbl.state.instance_name, event_table[type], details);
}
if(event_message->str) {
@@ -164,7 +156,6 @@ send_event(int type, const gchar *details, const gchar *custom_event) {
g_string_free(event_message, TRUE);
}
- g_free(p_val);
}
/* Transform gdk key events to our own events */
diff --git a/src/uzbl-browser b/src/uzbl-browser
index 88d3742..3c9562d 100755
--- a/src/uzbl-browser
+++ b/src/uzbl-browser
@@ -8,6 +8,8 @@
# to your $XDG_DATA_HOME/uzbl/scripts/ and edit them
PREFIX=/usr/local
+export PREFIX
+
EXAMPLES=$PREFIX/share/uzbl/examples
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
diff --git a/src/uzbl-core.c b/src/uzbl-core.c
index c960936..1110b02 100644
--- a/src/uzbl-core.c
+++ b/src/uzbl-core.c
@@ -415,36 +415,6 @@ find_existing_file(gchar* path_list) {
return NULL;
}
-
-/* Returns a new string with environment $variables expanded */
-gchar*
-parseenv (gchar* string) {
- extern char** environ;
- gchar* tmpstr = NULL, * out;
- int i = 0;
-
- if(!string)
- return NULL;
-
- out = g_strdup(string);
- while (environ[i] != NULL) {
- gchar** env = g_strsplit (environ[i], "=", 2);
- gchar* envname = g_strconcat ("$", env[0], NULL);
-
- if (g_strrstr (string, envname) != NULL) {
- tmpstr = out;
- out = str_replace(envname, env[1], out);
- g_free (tmpstr);
- }
-
- g_free (envname);
- g_strfreev (env); // somebody said this breaks uzbl
- i++;
- }
-
- return out;
-}
-
void
clean_up(void) {
if(uzbl.info.pid_str) {
@@ -696,9 +666,8 @@ set_var(WebKitWebView *page, GArray *argv, GString *result) {
gchar **split = g_strsplit(argv_idx(argv, 0), "=", 2);
if (split[0] != NULL) {
- gchar *value = parseenv(split[1] ? g_strchug(split[1]) : " ");
+ gchar *value = split[1] ? g_strchug(split[1]) : " ";
set_var_value(g_strstrip(split[0]), value);
- g_free(value);
}
g_strfreev(split);
}
@@ -928,14 +897,12 @@ void
include(WebKitWebView *page, GArray *argv, GString *result) {
(void) page;
(void) result;
- gchar *pe = NULL,
- *path = NULL;
+ gchar *path = argv_idx(argv, 0);
- if(!argv_idx(argv, 0))
+ if(!path)
return;
- pe = parseenv(argv_idx(argv, 0));
- if((path = find_existing_file(pe))) {
+ if((path = find_existing_file(path))) {
if(!for_each_line_in_file(path, parse_cmd_line_cb, NULL)) {
gchar *tmp = g_strdup_printf("File %s can not be read.", path);
send_event(COMMAND_ERROR, tmp, NULL);
@@ -945,7 +912,6 @@ include(WebKitWebView *page, GArray *argv, GString *result) {
send_event(FILE_INCLUDED, path, NULL);
g_free(path);
}
- g_free(pe);
}
void
@@ -1614,8 +1580,9 @@ init_fifo(gchar *dir) { /* return dir or, on error, free dir and return NULL */
if (g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_fifo, NULL)) {
if (uzbl.state.verbose)
printf ("init_fifo: created successfully as %s\n", path);
- send_event(FIFO_SET, path, NULL);
+ send_event(FIFO_SET, path, NULL);
uzbl.comm.fifo_path = path;
+ g_setenv("UZBL_FIFO", uzbl.comm.fifo_path, TRUE);
return dir;
} else g_warning ("init_fifo: could not add watch on %s\n", path);
} else g_warning ("init_fifo: can't open: %s\n", error->message);
@@ -1809,6 +1776,7 @@ init_socket(gchar *dir) { /* return dir or, on error, free dir and return NULL *
g_io_add_watch(chan, G_IO_IN|G_IO_HUP, (GIOFunc) control_socket, chan);
uzbl.comm.socket_path = path;
send_event(SOCKET_SET, path, NULL);
+ g_setenv("UZBL_SOCKET", uzbl.comm.socket_path, TRUE);
return dir;
}
} else g_warning ("init_socket: could not open in %s: %s\n", path, strerror(errno));
@@ -2076,6 +2044,7 @@ settings_init () {
send_event(COMMAND_ERROR, tmp, NULL);
g_free(tmp);
}
+ g_setenv("UZBL_CONFIG", s->config_file, TRUE);
} else if (uzbl.state.verbose)
printf ("No configuration file loaded.\n");
@@ -2358,12 +2327,16 @@ main (int argc, char* argv[]) {
"signal::changed", (GCallback)scroll_horiz_cb, NULL,
NULL);
+ gchar *xwin = g_strdup_printf("%d", (int)uzbl.xwin);
+ g_setenv("UZBL_XID", xwin, TRUE);
+
if(!uzbl.state.instance_name)
- uzbl.state.instance_name = itos((int)uzbl.xwin);
+ uzbl.state.instance_name = g_strdup(xwin);
- GString *tmp = g_string_new("");
- g_string_printf(tmp, "%d", getpid());
- uzbl.info.pid_str = g_string_free(tmp, FALSE);
+ g_free(xwin);
+
+ uzbl.info.pid_str = g_strdup_printf("%d", getpid());
+ g_setenv("UZBL_PID", uzbl.info.pid_str, TRUE);
send_event(INSTANCE_START, uzbl.info.pid_str, NULL);
if(uzbl.state.plug_mode) {
diff --git a/src/uzbl-core.h b/src/uzbl-core.h
index a62c3a6..b521f93 100644
--- a/src/uzbl-core.h
+++ b/src/uzbl-core.h
@@ -229,9 +229,6 @@ itos(int val);
gchar*
strfree(gchar *str);
-gchar*
-parseenv (gchar* string);
-
void
clean_up(void);