Mercurial > code > home > repos > homeauto
view lib/localdisplay.py @ 1562:c2ed44ed1e3c dependabot/pip/service/collector/twisted-19.7.0
Bump twisted from 19.2.0 to 19.7.0 in /service/collector
Bumps [twisted](https://github.com/twisted/twisted) from 19.2.0 to 19.7.0.
- [Release notes](https://github.com/twisted/twisted/releases)
- [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst)
- [Commits](https://github.com/twisted/twisted/compare/twisted-19.2.0...twisted-19.7.0)
Signed-off-by: dependabot[bot] <support@github.com>
author | dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
---|---|
date | Fri, 14 Feb 2020 10:01:26 +0000 |
parents | 6d67b23f3a75 |
children |
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 I might need something like xauth merge /run/gdm/auth-for-gdm-xxxxxx/database too and this isn't automated yet """ 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', '/usr/lib/xorg/Xorg']: continue except (psutil.error.AccessDenied, psutil.error.NoSuchProcess): continue 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') break else: raise ValueError("didn't find an Xorg process")