xref: /titanic_41/usr/src/cmd/vt/vtxlock.sh (revision de8c4a14ec9a49bad5e62b2cfa6c1ba21de1c708)
1#!/sbin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22#
23# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26
27#
28# $1 is the display to be locked.
29# /var/xauth/$1 is a symbolic link to the actual xauth file.
30#
31
32XSCREENSAVER_LOCK=/usr/openwin/bin/xscreensaver-command
33XSCREENSAVER_LOCKARGS="-lock"
34XSCREENSAVER_CHECKARGS="-time"
35XSCREENSAVER_LOCKED="locked"
36
37OTHER_LOCK=/usr/openwin/bin/xlock
38OTHER_LOCKARGS="-mode blank"
39
40XLSATOMS="/usr/openwin/bin/xlsatoms"
41XLSATOMS_ARGS="-name"
42CDE_ATOM=_DT_SM_PREFERENCES
43GNOME_ATOM=GNOME_SM_DESKTOP
44XSCREENSAVER_ATOM=SCREENSAVER
45
46DISPLAY=:$1; export DISPLAY
47XAUTHORITY=/var/xauth/$1; export XAUTHORITY
48
49#
50# Note that these text strings we're greping are not localized.
51#
52
53#
54# Is it GNOME?
55#
56if ${XLSATOMS} ${XLSATOMS_ARGS} ${GNOME_ATOM} 2>/dev/null \
57    | grep -w ${GNOME_ATOM} >/dev/null; then
58	#
59	# Is it xscreensaver?
60	#
61	# xscreensaver
62	if [ -x ${XSCREENSAVER_LOCK} ]; then
63		${XSCREENSAVER_LOCK} ${XSCREENSAVER_CHECKARGS} 2>/dev/null \
64		    | grep -w ${XSCREENSAVER_LOCKED} >/dev/null && exit 0
65
66		${XSCREENSAVER_LOCK} ${XSCREENSAVER_LOCKARGS} >/dev/null 2>&1 &
67		exit 0
68	fi
69fi
70
71#
72# Is it CDE?
73#
74if ${XLSATOMS} ${XLSATOMS_ARGS} ${CDE_ATOM} 2>/dev/null \
75    | grep -w ${CDE_ATOM} >/dev/null; then
76	exit 0
77fi
78
79# In other situations, use xlock as default.
80if [ -x ${OTHER_LOCK} ]; then
81	${OTHER_LOCK} ${OTHER_LOCKARGS} &
82	exit 0
83fi
84
85exit 0
86