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()
This commit is contained in:
enkore 2013-02-17 00:55:25 +01:00
parent 7e2c61c21a
commit 973abc928e

View File

@ -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)