You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.2 KiB

{% calculate path='/usr/bin', chmod='755', chown='root:root' %}
#!/bin/sh
#
# xfce4
#
# Copyright (C) 1999, 2003 Olivier Fourdan (fourdan@xfce.org)
# Copyright (C) 2011 Guido Berhoerster (guido+xfce.org@berhoerster.name)
# Copyright (C) 2011 Jarno Suni (8@iki.fi)
# Copyright (C) 2013 Mir Calculate (support@calculate-linux.ru)
#
# 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.
#
PATH=/bin:/usr/bin
export PATH
# spawn xflock4 before suspend contains DISPLAY without dot symbol
# wait several seconds before the dm-tool running if it's the suspend
SLEEPCMD=:
[ "${DISPLAY}" == "${DISPLAY/./}" ] && SLEEPCMD="sleep 2"
# lock screen by gnome-screensaver and activate lightdm user switch
if type dm-tool &>/dev/null; then
if type gnome-screensaver-command &>/dev/null; then
gnome-screensaver-command --lock &>/dev/null &&
$SLEEPCMD && dm-tool switch-to-greeter &>/dev/null && exit
else
dm-tool switch-to-greeter &>/dev/null && exit
fi
fi
# Lock by xscreensaver or gnome-screensaver, if a respective daemon is running
for lock_cmd in \
"xscreensaver-command -lock" \
"gnome-screensaver-command --lock"
do
$lock_cmd >/dev/null 2>&1 && exit
done
# else run another access locking utility, if installed
for lock_cmd in \
"xlock -mode blank" \
"slock"
do
set -- $lock_cmd
if command -v -- $1 >/dev/null 2>&1; then
$lock_cmd >/dev/null 2>&1 &
# turn off display backlight:
xset dpms force off
exit
fi
done
# else access locking failed
exit 1