#!/bin/sh
#
# Usage: cd-tkdesk [directory]
# Changes path of currently active browser to directory, or prints out
# its current path if no arg is given.

if [ $# -gt 0 ]; then
  DIR=$1
  if [ "$DIR" = "." ]; then
    DIR=`pwd`
  elif [ "$DIR" = ".." ]; then
    DIR=`dirname $(pwd)`
  elif [ "x`echo $DIR | grep '^[/~]'`" = "x" ]; then
    DIR=`pwd`/$DIR
  fi
  tkdeskclient "dsk_active dir $DIR" >/dev/null
else
  # read TkDesk's current dir from socket
  tkdeskclient "dsk_active dir"
fi
