From 6ff3e8ebf34178deedd0feb3bf141c526117c002 Mon Sep 17 00:00:00 2001 From: enkore Date: Mon, 18 Feb 2013 18:06:08 +0100 Subject: [PATCH] One may want to change the ordering ("injecting" items in the middle of i3status output, for example) --- i3pystatus/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/i3pystatus/__init__.py b/i3pystatus/__init__.py index 7eb0c48..dac594f 100644 --- a/i3pystatus/__init__.py +++ b/i3pystatus/__init__.py @@ -9,6 +9,7 @@ from contextlib import contextmanager class Module: output = None + position = 0 def registered(self, status_handler): """Called when this module is registered with a status handler""" @@ -90,13 +91,14 @@ class I3statusHandler: self.io = JSONIO(IOHandler(fd)) - def register(self, module): + def register(self, module, position=0): """Register a new module.""" self.modules.append(module) + module.position = position module.registered(self) def run(self): for j in self.io.read(): for module in self.modules: - j.insert(0, module.output) + j.insert(module.position, module.output)