From 973abc928ee0065cf7f50283f10b5acc58a61f86 Mon Sep 17 00:00:00 2001 From: enkore Date: Sun, 17 Feb 2013 00:55:25 +0100 Subject: [PATCH] Support for external file descriptors. Allows to run i3status directly from your __main__, like this: status.register(...) # and so on process = subprocess.Popen("i3status", stdout=subprocess.PIPE) status.fd = process.stdout # start the handler status.run() --- i3pystatus/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/i3pystatus/__init__.py b/i3pystatus/__init__.py index ffeee6f..586f954 100644 --- a/i3pystatus/__init__.py +++ b/i3pystatus/__init__.py @@ -40,6 +40,7 @@ class IntervalModule(AsyncModule): class I3statusHandler: modules = [] + fd = sys.stdin def __init__(self): pass @@ -61,7 +62,7 @@ class I3statusHandler: # try reading a line, removing any extra whitespace try: - line = sys.stdin.readline().strip() + line = self.fd.readline().decode("utf-8").strip() # i3status sends EOF, or an empty line if not line: sys.exit(3)