aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/uzbl/scripts/session.sh
diff options
context:
space:
mode:
authorGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-06-07 22:37:44 +0200
committerGravatar Dieter Plaetinck <dieter@plaetinck.be>2009-06-07 22:37:44 +0200
commit19489f84dbf0316222e27216c622929492d6fe4d (patch)
treecfa7f7f6c907edcc1b2c1e6cf53467b44146f935 /examples/data/uzbl/scripts/session.sh
parent6cccec4508d6b0290e04716459db6a5790b2a072 (diff)
make the whole xdg/dev directories /configs etc more sense making. now theres just one config you can directly copy into your home and use without editing. the same config can be used while developing, the Makefile just overrides 2 xdg variables. also the scripts can be a bit simpler now
Diffstat (limited to 'examples/data/uzbl/scripts/session.sh')
-rwxr-xr-xexamples/data/uzbl/scripts/session.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/examples/data/uzbl/scripts/session.sh b/examples/data/uzbl/scripts/session.sh
new file mode 100755
index 0000000..e2642c7
--- /dev/null
+++ b/examples/data/uzbl/scripts/session.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# Very simple session manager for uzbl. When called with "endsession" as the
+# argument, it'll backup $sessionfile, look for fifos in $fifodir and
+# instruct each of them to store their current url in $sessionfile and
+# terminate themselves. Run with "launch" as the argument and an instance of
+# uzbl will be launched for each stored url. "endinstance" is used internally
+# and doesn't need to be called manually at any point.
+# Add a line like 'bind quit = /path/to/session.sh endsession' to your config
+
+scriptfile=$0 # this script
+sessionfile=$XDG_DATA_HOME/uzbl/session # the file in which the "session" (i.e. urls) are stored
+configfile=$XDG_DATA_HOME/uzbl/config # uzbl configuration file
+UZBL="uzbl -c $configfile" # add custom flags and whatever here.
+
+fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere
+thisfifo="$4"
+act="$8"
+url="$6"
+
+if [ "$act." = "." ]; then
+ act="$1"
+fi
+
+
+case $act in
+ "launch" )
+ urls=$(cat $sessionfile)
+ if [ "$urls." = "." ]; then
+ $UZBL
+ else
+ for url in $urls; do
+ $UZBL --uri "$url" &
+ done
+ fi
+ exit 0
+ ;;
+
+ "endinstance" )
+ if [ "$url" != "(null)" ]; then
+ echo "$url" >> $sessionfile;
+ fi
+ echo "exit" > "$thisfifo"
+ ;;
+
+ "endsession" )
+ mv "$sessionfile" "$sessionfile~"
+ for fifo in $fifodir/uzbl_fifo_*; do
+ if [ "$fifo" != "$thisfifo" ]; then
+ echo "spawn $scriptfile endinstance" > "$fifo"
+ fi
+ done
+ echo "spawn $scriptfile endinstance" > "$thisfifo"
+ ;;
+
+ * ) echo "session manager: bad action"
+ echo "Usage: $scriptfile [COMMAND] where commands are:"
+ echo " launch - Restore a saved session or start a new one"
+ echo " endsession - Quit the running session. Must be called from uzbl"
+ ;;
+esac
+