#!/bin/sh
#
# Usage: pop-tkdesk file
# Opens the specified files by performing the default action of their
# associated TkDesk popup menu (this is the first menu item), or asks
# for a command to execute if no files are given.

if [ $# -gt 0 ]; then
  if [ $# -gt 1 ]; then
    echo "`basename $0`: can only display the popup for one file"
    exit 1
  fi
  
  FILES=
  for f in $@; do
    if [ -z "`echo $f | grep '^[/~]'`" ]; then
      FILES="`pwd`/$f $FILES"
    else
      FILES="$f $FILES"
    fi
  done
  tkdeskclient "cd `pwd`; dsk_show_popup `echo $FILES`; cd" >/dev/null 
else
  echo "usage: pop-tkdesk file"
  exit 2
fi
