Skip to content

Commit

Permalink
Merge pull request #132 from pmav99/issue-77
Browse files Browse the repository at this point in the history
Fix #77 - Stop throwing exceptions if $WINDOWID has not been set.
  • Loading branch information
dschep committed Jan 11, 2017
2 parents 6ab15e0 + 5c2128e commit bab1dc8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ntfy/terminal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from os import environ, ttyname
from subprocess import check_output, Popen, PIPE
from sys import platform, stdout
import shlex


def get_tty():
Expand All @@ -10,9 +11,10 @@ def get_tty():


def linux_window_is_focused():
window_id = int(check_output(['xprop', '-root', '\t$0',
'_NET_ACTIVE_WINDOW']).split()[1], 16)
return int(environ['WINDOWID']) == window_id
xprop_cmd = shlex.split('xprop -root _NET_ACTIVE_WINDOW')
xprop_window_id = int(check_output(xprop_cmd).split()[-1], 16)
env_window_id = int(environ.get('WINDOWID', '0'))
return env_window_id == xprop_window_id


def osascript_tell(app, script):
Expand Down

0 comments on commit bab1dc8

Please sign in to comment.