#!/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"
else
  # [todo] read TkDesk's current dir from socket
  echo 'puts [send tkdesk dsk_active dir]; exit' | tkdesksh
fi
