Merge branch 'less_closed'
[unleashed.git] / usr / src / cmd / vt / vtxlock.sh
blob4ed6e55c8651270e36f6a6adcf91ac59a780e340
1 #!/sbin/sh
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # $1 is the display to be locked.
29 # /var/xauth/$1 is a symbolic link to the actual xauth file.
32 XSCREENSAVER_LOCK=/usr/openwin/bin/xscreensaver-command
33 XSCREENSAVER_LOCKARGS="-lock"
34 XSCREENSAVER_CHECKARGS="-time"
35 XSCREENSAVER_LOCKED="locked"
37 OTHER_LOCK=/usr/openwin/bin/xlock
38 OTHER_LOCKARGS="-mode blank"
40 XLSATOMS="/usr/openwin/bin/xlsatoms"
41 XLSATOMS_ARGS="-name"
42 CDE_ATOM=_DT_SM_PREFERENCES
43 GNOME_ATOM=GNOME_SM_DESKTOP
44 XSCREENSAVER_ATOM=SCREENSAVER
46 DISPLAY=:$1; export DISPLAY
47 XAUTHORITY=/var/xauth/$1; export XAUTHORITY
50 # Note that these text strings we're greping are not localized.
54 # Is it GNOME?
56 if ${XLSATOMS} ${XLSATOMS_ARGS} ${GNOME_ATOM} 2>/dev/null \
57 | grep -w ${GNOME_ATOM} >/dev/null; then
59 # Is it xscreensaver?
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
66 ${XSCREENSAVER_LOCK} ${XSCREENSAVER_LOCKARGS} >/dev/null 2>&1 &
67 exit 0
72 # Is it CDE?
74 if ${XLSATOMS} ${XLSATOMS_ARGS} ${CDE_ATOM} 2>/dev/null \
75 | grep -w ${CDE_ATOM} >/dev/null; then
76 exit 0
79 # In other situations, use xlock as default.
80 if [ -x ${OTHER_LOCK} ]; then
81 ${OTHER_LOCK} ${OTHER_LOCKARGS} &
82 exit 0
85 exit 0