diff options
Diffstat (limited to 'examples/scripts/session.sh')
-rwxr-xr-x | examples/scripts/session.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/examples/scripts/session.sh b/examples/scripts/session.sh new file mode 100755 index 0000000..5087af0 --- /dev/null +++ b/examples/scripts/session.sh @@ -0,0 +1,42 @@ +#!/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 +# 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. + + +scriptfile=$XDG_CONFIG_HOME/uzbl/session.sh # 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. + +fifodir=/tmp # remember to change this if you instructed uzbl to put its fifos elsewhere +thisfifo="$5" +act="$1" +url="$7" + +case $act in + "launch" ) + for url in $(cat $sessionfile); do + $UZBL --uri "$url" & + done + 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 + if [ "$fifo" != "$thisfifo" ]; then + echo "spawn $scriptfile endinstance" > "$fifo" + fi + done + echo "spawn $scriptfile endinstance" > "$thisfifo";; + * ) echo "session manager: bad action";; +esac + |