diff options
author | Jochen Sprickerhof <jochen@sprickerhof.de> | 2010-11-26 23:06:32 +0100 |
---|---|---|
committer | Jochen Sprickerhof <jochen@sprickerhof.de> | 2010-11-28 13:25:46 +0100 |
commit | 94924cbb5fdc28ab8c1faa2c346eebbddc966598 (patch) | |
tree | 811f9b86ce0eeacf10262a6ac2d9f0415ba43713 /examples/data/scripts/session.sh | |
parent | 518004933b6d110d2a6d140f86c759dd4e713607 (diff) |
improved session.sh script to work standalone
- use readlink to get the absolute path of the script
- works standalone as well, just run it and it will either save all
running uzbl instances or reopen them
- changed backup of sessionfile to launch action, so you can use
endinstance from uzbl as well. For example to save a link to read it
later
Diffstat (limited to 'examples/data/scripts/session.sh')
-rwxr-xr-x | examples/data/scripts/session.sh | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh index 203cd52..a27c577 100755 --- a/examples/data/scripts/session.sh +++ b/examples/data/scripts/session.sh @@ -32,9 +32,13 @@ if [ $# -gt 1 ]; then . "$UZBL_UTIL_DIR"/uzbl-args.sh 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") @@ -45,6 +49,7 @@ case $act in $UZBL --uri "$url" & disown done + mv "$UZBL_SESSION_FILE" "$UZBL_SESSION_FILE~" fi ;; @@ -58,13 +63,12 @@ case $act in ;; "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" ;; * ) |