Skip to content

Commit

Permalink
Don't barf on xprop missing or not returning a window id
Browse files Browse the repository at this point in the history
closes #130
  • Loading branch information
dschep committed Nov 28, 2017
1 parent e585042 commit 7852281
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ntfy/terminal.py
Expand Up @@ -6,7 +6,15 @@

def linux_window_is_focused():
xprop_cmd = shlex.split('xprop -root _NET_ACTIVE_WINDOW')
xprop_window_id = int(check_output(xprop_cmd).split()[-1], 16)
try:
xprop_window_id = int(check_output(xprop_cmd).split()[-1], 16)
except ValueError:
return False
except OSError as e:
if 'No such file' in e.strerror:
return False
else:
raise
env_window_id = int(environ.get('WINDOWID', '0'))
return env_window_id == xprop_window_id

Expand Down

0 comments on commit 7852281

Please sign in to comment.