Mercurial > code > home > repos > homeauto
view lib/localdisplay.py @ 907:38eb2d125738
schematic
Ignore-this: 74bbb5c125d695715fd7b732ff4aad37
darcs-hash:20130831212020-312f9-6ea9f815a5bcc7a7b975b5f49aad4ed404ca5f97
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Sat, 31 Aug 2013 14:20:20 -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")