Created
May 18, 2017 16:37
-
-
Save cicorias/65280637dc795c18c896b75fea255885 to your computer and use it in GitHub Desktop.
macOS lock screen 1 line command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Do our work in the temporary directory that gets cleaned on boot | |
cd /tmp | |
# Create the source file | |
cat > main.m <<END_OF_FILE | |
#import <objc/runtime.h> | |
#import <Foundation/Foundation.h> | |
int main () { | |
NSBundle *bundle = [NSBundle bundleWithPath:@"/Applications/Utilities/Keychain Access.app/Contents/Resources/Keychain.menu"]; | |
Class principalClass = [bundle principalClass]; | |
id instance = [[principalClass alloc] init]; | |
[instance performSelector:@selector(_lockScreenMenuHit:) withObject:nil]; | |
return 0; | |
} | |
END_OF_FILE | |
# Compile the source file | |
clang -framework Foundation main.m -o lockscreen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment