Skip to content

Commit fb57d1a

Browse files
committed
prevent unexpected warning when macos is locked
1 parent dfb2a9c commit fb57d1a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

ntfy/terminal.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from os import environ, ttyname
33
from subprocess import PIPE, Popen, check_output
44
from sys import platform, stdout
5+
from screensaver import is_locked
56

67

78
def linux_window_is_focused():
@@ -36,6 +37,11 @@ def darwin_iterm2_shell_is_focused():
3637

3738

3839
def darwin_terminal_shell_is_focused():
40+
# The osascript for detecting window focus throws an error if the screen is
41+
# locked, so we'll check that first.
42+
if is_locked() == True:
43+
return False
44+
3945
focused_tty = osascript_tell(
4046
'Terminal',
4147
'tty of (first tab of (first window whose frontmost is true) '

0 commit comments

Comments
 (0)