We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fb57d1a commit d95250bCopy full SHA for d95250b
1 file changed
ntfy/screensaver.py
@@ -97,12 +97,12 @@ def macos_detect():
97
98
99
def macos_is_locked():
100
- # Strictly-speaking, this detects whether or not the screensaver is running. The screensaver
101
- # may or may not be locked.
102
- cmd = '''tell application "System Events"
103
- get running of screen saver preferences
104
- end tell'''
105
- return check_output([ 'osascript', '-e', cmd ]) == b'true\n'
+ # https: // stackoverflow.com/questions/11505255/osx-check-if-the-screen-is-locked
+ import Quartz
+ d = Quartz.CGSessionCopyCurrentDictionary()
+ screenIsLocked = d.get("CGSSessionScreenIsLocked", 0) == 1
+
+ return screenIsLocked
106
107
108
def is_locked():
0 commit comments