OSX Snippets: fast user switch from the command line

Copy this into your favorite editor, save and run for the commandline:



#!/bin/sh
MENUEXTRAS="/System/Library/CoreServices/Menu Extras"
CGSESSION="$MENUEXTRAS/User.menu/Contents/Resources/CGSession"
if [[ -z $1 ]]; then
“$CGSESSION” -suspend
else
USERID=`id -u $1`;
if [[ -z $USERID ]]; then
exit -1;
fi;
“$CGSESSION” -switchToUserID $USERID
fi;

Tags:
permalinkRead More CommentComments (0) Catosx, snippet

Leave a Reply

You must be logged in to post a comment.