aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/session.sh
diff options
context:
space:
mode:
Diffstat (limited to 'examples/data/scripts/session.sh')
-rwxr-xr-xexamples/data/scripts/session.sh28
1 files changed, 15 insertions, 13 deletions
diff --git a/examples/data/scripts/session.sh b/examples/data/scripts/session.sh
index ee09cf2..4e7bfd1 100755
--- a/examples/data/scripts/session.sh
+++ b/examples/data/scripts/session.sh
@@ -18,28 +18,30 @@
if [ -z "$UZBL_UTIL_DIR" ]; then
# we're being run standalone, we have to figure out where $UZBL_UTIL_DIR is
# using the same logic as uzbl-browser does.
- UZBL_UTIL_DIR=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/scripts/util
+ UZBL_UTIL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/scripts/util"
if ! [ -d "$UZBL_UTIL_DIR" ]; then
- PREFIX=$(grep '^PREFIX' "$(which uzbl-browser)" | sed 's/.*=//')
- UZBL_UTIL_DIR=$PREFIX/share/uzbl/examples/data/scripts/util
+ PREFIX="$( grep '^PREFIX' "$( which uzbl-browser )" | sed -e 's/.*=//' )"
+ UZBL_UTIL_DIR="$PREFIX/share/uzbl/examples/data/scripts/util"
fi
fi
-. "$UZBL_UTIL_DIR"/uzbl-dir.sh
+. "$UZBL_UTIL_DIR/uzbl-dir.sh"
+
[ -d "$UZBL_DATA_DIR" ] || exit 1
-UZBL="uzbl-browser -c $UZBL_CONFIG_FILE" # add custom flags and whatever here.
+UZBL="uzbl-browser -c \"$UZBL_CONFIG_FILE\"" # add custom flags and whatever here.
-scriptfile=$(readlink -f $0) # this script
+scriptfile="$( readlink -f "$0" )" # this script
act="$1"
+shift
if [ -z "$act" ]; then
[ -f "$UZBL_SESSION_FILE" ] && act="launch" || act="endsession"
fi
case $act in
- "launch" )
- urls=$(cat "$UZBL_SESSION_FILE")
+ "launch")
+ urls="$( cat "$UZBL_SESSION_FILE" )"
if [ -z "$urls" ]; then
$UZBL
else
@@ -50,17 +52,17 @@ case $act in
fi
;;
- "endinstance" )
+ "endinstance")
if [ -z "$UZBL_FIFO" ]; then
echo "session manager: endinstance must be called from uzbl"
exit 1
fi
[ "$UZBL_URI" != "(null)" ] && echo "$UZBL_URI" >> "$UZBL_SESSION_FILE"
- echo exit > "$UZBL_FIFO"
+ echo "exit" > "$UZBL_FIFO"
;;
- "endsession" )
- for fifo in "$UZBL_FIFO_DIR"/uzbl_fifo_*; do
+ "endsession")
+ for fifo in "$UZBL_FIFO_DIR/uzbl_fifo_*"; do
if [ "$fifo" != "$UZBL_FIFO" ]; then
echo "spawn $scriptfile endinstance" > "$fifo"
fi
@@ -68,7 +70,7 @@ case $act in
[ -z "$UZBL_FIFO" ] || echo "spawn $scriptfile endinstance" > "$UZBL_FIFO"
;;
- * )
+ *)
echo "session manager: bad action"
echo "Usage: $scriptfile [COMMAND] where commands are:"
echo " launch - Restore a saved session or start a new one"