mirror of
https://github.com/NaomiAmethyst/dots.git
synced 2025-04-13 09:30:06 +00:00
lock: fixed locking on Macs and cleaned up the code.
This commit is contained in:
parent
624080c735
commit
47e3200daa
1 changed files with 10 additions and 9 deletions
19
lock
19
lock
|
@ -2,14 +2,21 @@
|
||||||
|
|
||||||
# Yell if they are trying to lock remotely. This won't work.
|
# Yell if they are trying to lock remotely. This won't work.
|
||||||
# Even if it does, it's wrong.
|
# Even if it does, it's wrong.
|
||||||
if [ "${SSH_TTY}" ] ; then
|
if [ "${SSH_TTY}" ] && [ -z "${STY}" ] ; then
|
||||||
echo "You're doing it wrong. Don't try to lock a remote computer."
|
echo "You're doing it wrong. Don't try to lock a remote computer."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Graphically locking on Macs is simple.
|
||||||
|
# If we're not in screen, attempt to graphically lock it.
|
||||||
|
if [ `uname -s` = 'Darwin' ] && [ -z "${STY}" ] ; then
|
||||||
|
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
# Handle non-graphical locking
|
# Handle non-graphical locking
|
||||||
if [ -z $DISPLAY ] ; then
|
if [ -z "${DISPLAY}" ] ; then
|
||||||
if [ -z $STY ] ; then # not running screen
|
if [ -z "${STY}" ] ; then # not running screen
|
||||||
if ( command -v vlock >/dev/null 2>/dev/null ) ; then
|
if ( command -v vlock >/dev/null 2>/dev/null ) ; then
|
||||||
vlock
|
vlock
|
||||||
exit
|
exit
|
||||||
|
@ -22,12 +29,6 @@ if [ -z $DISPLAY ] ; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Locking on Macs is simple.
|
|
||||||
if [ `uname -s` = 'Darwin' ] ; then
|
|
||||||
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try to lock sanely on X11.
|
# Try to lock sanely on X11.
|
||||||
# Certain combinations of desktop managers and locking programs
|
# Certain combinations of desktop managers and locking programs
|
||||||
# allow new sessions to be started.
|
# allow new sessions to be started.
|
||||||
|
|
Loading…
Add table
Reference in a new issue