aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorGravatar bobpaul <bobpaul@lappy486.(none)>2009-06-02 16:58:50 -0500
committerGravatar bobpaul <bobpaul@lappy486.(none)>2009-06-02 16:58:50 -0500
commitbcae0ddb8615d2d5de180b2c781dd2ddda9332c2 (patch)
treed62cd2a84d9f069526ef09ed259988981ef90d76 /examples
parent663c7a0a58f7f463d560160755bf9c6b71e71213 (diff)
Fixed session.sh script.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/scripts/session.sh40
1 files changed, 30 insertions, 10 deletions
diff --git a/examples/scripts/session.sh b/examples/scripts/session.sh
index b8e2bd6..6d2a64d 100755
--- a/examples/scripts/session.sh
+++ b/examples/scripts/session.sh
@@ -1,34 +1,48 @@
#!/bin/bash
# Very simple session manager for uzbl. When called with "endsession" as the
-# argument, it'lla empty the sessionfile, look for fifos in $fifodir and
+# 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=$XDG_CONFIG_HOME/uzbl/session.sh # this script
+scriptfile=$0 # this script
sessionfile=$XDG_DATA_HOME/uzbl/session # the file in which the "session" (i.e. urls) are stored
-UZBL="uzbl" # add custom flags and whatever here.
+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" )
- for url in $(cat $sessionfile); do
- $UZBL --uri "$url" &
- done
- exit 0;;
+ 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" )
echo -n "" > "$sessionfile"
for fifo in $fifodir/uzbl_fifo_*; do
@@ -36,7 +50,13 @@ case $act in
echo "spawn $scriptfile endinstance" > "$fifo"
fi
done
- echo "spawn $scriptfile endinstance" > "$thisfifo";;
- * ) echo "session manager: bad action";;
+ 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