Mercurial > code > home > repos > homeauto
changeset 352:9ee169ba3f0e
better X detection in localdisplay
Ignore-this: 883e8946dfb27ea4ef71df7beb4c7d01
author | drewp@bigasterisk.com |
---|---|
date | Mon, 03 Sep 2018 00:47:10 -0700 |
parents | 7716b1810d6c |
children | d9cc239a90e4 |
files | lib/localdisplay.py |
diffstat | 1 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/localdisplay.py Mon Sep 03 00:45:34 2018 -0700 +++ b/lib/localdisplay.py Mon Sep 03 00:47:10 2018 -0700 @@ -10,13 +10,25 @@ for pid in psutil.get_pid_list(): try: proc = psutil.Process(pid) - if proc.exe not in ['/usr/bin/Xorg', '/usr/bin/X', '/usr/bin/X11/X']: + if proc.exe not in ['/usr/bin/Xorg', '/usr/bin/X', '/usr/bin/X11/X', '/usr/lib/xorg/Xorg']: continue except (psutil.error.AccessDenied, psutil.error.NoSuchProcess): continue - display = [arg for arg in proc.cmdline if not arg.startswith('-')][1] - if display == 'tcp': # ?? - display = ":0.0" + argIter = iter(proc.cmdline) + while True: + arg = argIter.next() + if arg in ['-background']: + argIter.next() + continue + if arg in ['-nolisten']: + continue + if arg.startswith(':'): + display = arg + break + if arg == 'tcp': + display = ':0.0' + break + assert display.startswith(':'), display os.environ['DISPLAY'] = display os.environ['XAUTHORITY'] = os.path.expanduser('~/.Xauthority')