Skip to content

Instantly share code, notes, and snippets.

@anapsix
Created February 8, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anapsix/de1370a10b08dd0a442a83e8193642ee to your computer and use it in GitHub Desktop.
Save anapsix/de1370a10b08dd0a442a83e8193642ee to your computer and use it in GitHub Desktop.
lockscreen command line utility on mac

Make a lockscreen CLI utility on your Mac

ATTENTION: use at your own risk, no warranty of any kind This seems to work in High Sierra, but may break in future versions

cat > /tmp/lockscreen.c <<EOF
// lockscreen.c
extern void SACLockScreenImmediate();
int main()
{
  SACLockScreenImmediate();
  return 0;
}
EOF

clang -F /System/Library/PrivateFrameworks -framework login -o /tmp/lockscreen /tmp/lockscreen.c
cp /tmp/lockscreen /usr/local/bin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment