My collection of plugins for the Qtile window manager.
git clone https://mcol.xyz/code/qtools
Log | Files | Refs | README

commit 42fdcbfc1be7bd1c228a535cb432c682ac0f80d9
parent 897450cfa10532a7b6b55d56368a85ec5b2e9fbc
Author: mcol <mcol@posteo.net>
Date:   Tue,  2 Jun 2020 20:41:39 +0100

xresources: get DISPLAY if not provided

Diffstat:
Mqtools/xresources/xresources.py | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/qtools/xresources/xresources.py b/qtools/xresources/xresources.py @@ -3,19 +3,21 @@ Qtile helper to get X resources from the root window. """ +import os + import xcffib import xcffib.xproto from libqtile.log_utils import logger -def get(DISPLAY, defaults=None): +def get(DISPLAY=None, defaults=None): """ Get the X resources in an X servers resource manager. Parameters ========== - DISPLAY : str - DISPLAY name to query. + DISPLAY : str (optional) + DISPLAY name to query. This will be taken from the environment if not specified. defaults : dict (optional) Default values to act as a fallback for missing values or in the event of a @@ -31,6 +33,9 @@ def get(DISPLAY, defaults=None): """ resources = defaults if defaults else {} + if DISPLAY is None: + DISPLAY = os.environ.get("DISPLAY") + try: conn = xcffib.connect(display=DISPLAY) except xcffib.ConnectionException as e: