#!/bin/zsh -f

 
if [[ $OSTYPE[7] -lt 7 ]];then
     print "Fast User Switching is not available in OSX version $os_version"
     return 1
fi


if [[ -z $1 ]]; then
  /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
else
  USERID=`/usr/bin/id -u $1`;
  if [[ -z $USERID ]]; then
    return -1;
  fi
  /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID $USERID
fi

