Mercurial > code > home > repos > homeauto
view lib/localdisplay.py @ 111:e4a4ee70a514
switch reasoning from restkit to async cyclone http client
Ignore-this: d7b8d0dba6374315a6eba63ca13e7c69
author | drewp@bigasterisk.com |
---|---|
date | Mon, 02 Sep 2013 20:57:18 -0700 |
parents | ef639d892e77 |
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")