logwin 924 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. # This is a script to suspend you login
  3. if [ $# -gt 0 ]; then
  4. if [ $# == 2 ]; then
  5. ARG1=$1
  6. if [ $ARG1 == "-s" -o $ARG1 == "--switch" ]; then
  7. USER_NAME=$2
  8. NAME_UID=`nigrep '^uid$' / /users|grep $USER_NAME|grep -o "[0-9][0-9]*$"`
  9. if [ ! "$NAME_UID" ]; then
  10. NAME_UID=`nigrep '^realname$' / /users|grep -i $USER_NAME|cut -d: -f 1|grep -io "[^/][a-z][a-z]*$"`
  11. fi
  12. if [ ! "$NAME_UID" ]; then
  13. echo "no such user found"
  14. else
  15. CUR_UID=`nigrep '^uid$' / /users|grep $(whoami)|grep -io "[0-9][0-9]*$"`
  16. if [ $CUR_UID == "$NAME_UID" ]; then
  17. echo "already that user"
  18. else
  19. /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID $NAME_UID
  20. fi
  21. fi
  22. else
  23. echo "bad augment"
  24. fi
  25. else
  26. echo "not enough augments"
  27. fi
  28. else
  29. /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
  30. fi