Last active
November 7, 2020 14:30
-
-
Save nikolay-n/2d89c773c5a2913e9392cf64117e3a1a to your computer and use it in GitHub Desktop.
Checks lock screen status
This file contains 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
from Foundation import NSBundle | |
import objc | |
BIT_WIDTH = 32 | |
INT_MAX = 2**(BIT_WIDTH-1)-1 | |
MobileKeyBag = NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/MobileKeyBag.framework') | |
objc.loadBundleFunctions(MobileKeyBag, globals(), [('MKBDeviceGetGracePeriod', '@@')]) | |
grace = MKBDeviceGetGracePeriod({}); | |
try: | |
p = grace["GracePeriod"] | |
if p == INT_MAX: | |
print("Screen lock disabled") | |
else: | |
print "Screen lock {}".format("is not set" if p == -1 else "is set, grace period {}".format(p)) | |
except: | |
print("Something wrong!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment