#!/bin/sh

#
# WindowMaker
#
# Dock undockable applications
#
# Must exit wmaker before running, or changes will be overwritten.
#

# set this to the path for your dock configuration file

DOCKFILE=$HOME/gnustep/Library/WindowMaker/dock




if [ ! -f $DOCKFILE ]; then
	echo "$0: dock config file not found. Edit script and change DOCKFILE"
	exit 1
fi

if [ $# -lt 3 ]; then
	echo "Syntax:"
	echo "$0 <instance> <class> <command>"
	echo
	echo "example:"
	echo "	$0 Navigator Netscape netscape"
	echo
	echo "Supply . as <instance> or <class> if it is not available"
	echo "To get the instance and class information, double click the"
	echo "window titlebar with the 3rd mouse button or use xprop"
	echo "in the desired window and look for the WM_CLASS line"
	echo "Note 1: you must exit WindowMaker before using this program"
	echo "Note 2: do NOT expect normal dock behaviour with apps docked this way"
       	exit 1
fi


if [ $1 = . -a $2 = . ]; then
	echo "At least one of instance and class information must be available"
	exit 1
fi

echo $1 >> $DOCKFILE
echo $2 >> $DOCKFILE

shift 2
app=$1
argc=$#
echo "-1 $argc 0 1" >> $DOCKFILE

while [ $# -gt 0 ]; do
	echo $1 >> $DOCKFILE
	shift
done

echo "$app docked."
