Thursday, March 31, 2022

mac auto login and lock

auto lock mac after auto login 

cat autolock.sh 

#!/bin/bash

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

exit 0


For BigSur and monterey, CGSession is not available any more.

#!/bin/zsh

osascript -e 'tell app "System Events" to key code 12 using {control down, command down}'

https://apple.stackexchange.com/questions/406616/replacement-for-cgsession-suspend 



No comments:

Post a Comment