#!/bin/sh
#
#  xfce4
#
#  Copyright (C) 1999, 2003 Olivier Fourdan (fourdan@xfce.org)
#  Copyright (C) 2011       Guido Berhoerster (guido+xfce.org@berhoerster.name)
#  Copyright (C) 2014       Jarno Suni (8@iki.fi)
#
#  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.
#
set -o nounset
set -o errexit
PATH=/bin:/usr/bin
export PATH

# Lock by xscreensaver, gnome-screensaver or light-locker,
# if a respective daemon is running
if pidof xscreensaver >/dev/null; then
    xscreensaver-command -lock >/dev/null
elif pidof gnome-screensaver >/dev/null; then
    gnome-screensaver-command --lock
elif pidof light-locker >/dev/null; then
	light-locker-command --lock
# or use another available utility to lock.
# (Use "which" instead of built-in "command -v",
# if that is more portable.)
elif command -v i3lock >/dev/null; then
    i3lock -d
elif command -v slock >/dev/null; then
    slock &
elif command -v xlock >/dev/null; then
	xlock -mode blank &
else 
	# else access locking failed
	exit 1
fi
