#!/bin/sh
kc=${KDEDIR-/opt/kde}/bin/kfmclient
if [ ! -f $kc ]; then
	# Try one more...
	kc=/usr/bin/kfmclient
fi
if [ ! -f $kc ]; then
	echo "No KDE installed" >&2
	exit 1
fi
if [ $# = 0 ]; then
	echo "Usage: $0 <URL>" >&2
	exit 1
fi
for file
do
case "$file" in
	/*)
		$kc exec "file:$file"
		;;
	www.*)
		$kc exec "http://$file"
		;;
	ftp.*)
		$kc exec "ftp://$file"
		;;
	http://*|ftp://*|file:*)
		# No other protocols supported right now
		$kc exec "$file"
		;;
	# Try to map everything else to a host name or a local file
	*)
		if [ -f "$file" ]; then
			$kc exec "file:$PWD/$file"
		elif [ -d "$file" ]; then
			$kc exec "file:$PWD/$file/"
		else
			$kc exec "http://$file"
		fi
		;;
esac
done
