Mercurial > code > home > repos > homeauto
view lib/localdisplay.py @ 894:3ad6b7bcdaff
shuttlepro: some old changes
Ignore-this: 980a9ffa0b084bd46db880b4b3621a02
darcs-hash:20130802150605-312f9-c293c465516f42c8397aad7f48c228526cf46295
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Fri, 02 Aug 2013 08:06:05 -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")