# HG changeset patch # User drewp # Date 1535960830 25200 # Node ID 6d67b23f3a75a9309d9c684dc0a601b96a79c4dc # Parent ee168d55524a0a511ee565ddc3d7c87961b3ed81 better X detection in localdisplay Ignore-this: 883e8946dfb27ea4ef71df7beb4c7d01 darcs-hash:754a1ee006a86339dc236e87a57694a2763ee882 diff -r ee168d55524a -r 6d67b23f3a75 lib/localdisplay.py --- 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')