1234567891011121314151617181920212223242526272829303132 |
- #!/bin/sh
- # This is a script to suspend you login
- if [ $# -gt 0 ]; then
- if [ $# == 2 ]; then
- ARG1=$1
- if [ $ARG1 == "-s" -o $ARG1 == "--switch" ]; then
- USER_NAME=$2
- NAME_UID=`nigrep '^uid$' / /users|grep $USER_NAME|grep -o "[0-9][0-9]*$"`
- if [ ! "$NAME_UID" ]; then
- NAME_UID=`nigrep '^realname$' / /users|grep -i $USER_NAME|cut -d: -f 1|grep -io "[^/][a-z][a-z]*$"`
- fi
- if [ ! "$NAME_UID" ]; then
- echo "no such user found"
- else
- CUR_UID=`nigrep '^uid$' / /users|grep $(whoami)|grep -io "[0-9][0-9]*$"`
- if [ $CUR_UID == "$NAME_UID" ]; then
- echo "already that user"
- else
- /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID $NAME_UID
- fi
- fi
- else
- echo "bad augment"
- fi
- else
- echo "not enough augments"
- fi
- else
- /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
- fi
|