Mercurial > code > home > repos > homeauto
view lib/localdisplay.py @ 909:c80a23d86ea9
rev2 pin names
Ignore-this: 6bd747872c316e79b851e9cb47d4d1ab
darcs-hash:20130831230948-312f9-2b6d59abc2b1b6193cfd00ef574c6030224852c8
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sat, 31 Aug 2013 16:09:48 -0700 |
parents | 2d055bce2e60 |
children | 9155e9a605ec |
line wrap: on
line source
import psutil, os def setDisplayToLocalX(): """ set DISPLAY env var in this process to the id of the X process on localhost """ for pid in psutil.get_pid_list(): try: proc = psutil.Process(pid) if proc.exe not in ['/usr/bin/Xorg', '/usr/bin/X']: continue except (psutil.error.AccessDenied, psutil.error.NoSuchProcess): continue display = proc.cmdline[1] assert display.startswith(':'), display os.environ['DISPLAY'] = display break else: raise ValueError("didn't find an Xorg process")