#!/bin/sh
#
# $Id: xscreenlock,v 1.1 2003/01/24 16:56:23 ldv Exp $
# Copyright (C) 2003  Dmitry V. Levin <ldv@altlinux.org>
#
# Wrapper for xscreensaver and xlockmore.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

unset n XSCREEN_CUSTOM XSCREEN_SERVER XSCREEN_CLIENT XSCREEN_XLOCK ||:
XSCREEN_CUSTOM="$HOME/.xscreenlock"
XSCREEN_SERVER="/usr/X11R6/bin/xscreensaver"
XSCREEN_CLIENT="/usr/X11R6/bin/xscreensaver-command"
XSCREEN_XLOCK="/usr/X11R6/bin/xlock"

if [ -x "$XSCREEN_CUSTOM" ]; then
	exec "$XSCREEN_CUSTOM" "$@"
fi

if [ -x "$XSCREEN_SERVER" -a -x "$XSCREEN_CLIENT" ]; then
	if ! "$XSCREEN_CLIENT" -version >/dev/null 2>&1; then
		"$XSCREEN_SERVER" -nosplash </dev/null &
		for n in `seq 1 5`; do
			"$XSCREEN_CLIENT" -version >/dev/null 2>&1 && break
			usleep 100000
		done
	fi
	"$XSCREEN_CLIENT" -lock
elif [ -x "$XSCREEN_XLOCK" ]; then
	"$XSCREEN_XLOCK"
fi

