Last active
May 12, 2021 21:53
-
-
Save antlauzon/a846aab85269e3edbc399c8903219df6 to your computer and use it in GitHub Desktop.
islocked
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
#!/usr/bin/env python3 | |
import sys | |
import os | |
import sys | |
import Quartz | |
d = Quartz.CGSessionCopyCurrentDictionary() | |
LOCKED_FILE = '$HOME/tmp/.locked' | |
if d.get('CGSSessionScreenIsLocked') in ['1', 1]: | |
with open(LOCKED_FILE, 'w') as f: | |
f.write(int(time.time())) | |
sys.exit(0) | |
try: | |
os.remove(LOCKED_FILE) | |
except: | |
pass | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment