From dd7b5ef3462d2fa9db70eced7b4d52bb91b32bed Mon Sep 17 00:00:00 2001 From: enkore Date: Sat, 23 Feb 2013 20:41:42 +0100 Subject: [PATCH] i3bar has some issues with locale-handling I guess. It reliably crashes i3pystatus, but only if started by i3bar. Meh. I can't tell if this locale issue is local (ha-ha) or everyone is affected. --- i3pystatus/__init__.py | 8 ++++++-- i3pystatus/clock.py | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/i3pystatus/__init__.py b/i3pystatus/__init__.py index 742eed2..9242ed9 100644 --- a/i3pystatus/__init__.py +++ b/i3pystatus/__init__.py @@ -109,6 +109,10 @@ class Module(SettingsBase): def registered(self, status_handler): """Called when this module is registered with a status handler""" + def inject(self, json): + if self.output: + json.insert(self.position, self.output) + class AsyncModule(Module): def registered(self, status_handler): self.thread = Thread(target=self.mainloop) @@ -205,7 +209,7 @@ class StandaloneIO(IOHandler): n = -1 proto = ( - '{"version": 1}', + '{"version":1}', "[", "[]", ",[]", @@ -298,5 +302,5 @@ class i3pystatus: def run(self): for j in JSONIO(self.io).read(): for module in self.modules: - j.insert(module.position, module.output) + module.inject(j) I3statusHandler = i3pystatus diff --git a/i3pystatus/clock.py b/i3pystatus/clock.py index b2373d5..4e48bb8 100644 --- a/i3pystatus/clock.py +++ b/i3pystatus/clock.py @@ -14,10 +14,21 @@ class Clock(IntervalModule): format = None def init(self): - lang = os.environ.get('LANG', None) - if lang: - locale.setlocale(locale.LC_ALL, lang) if self.format is None: + # + # WARNING + # i3bar does something with the locale, wich probably + # crashes i3pystatus when the code block below is run. + # I don't know how to debug i3bar (I doubt it has any + # debugging facilities). + # + # If your i3bar stays blank after enabling clock, well, + # just set the format string and it should work :-) + # + + lang = os.environ.get('LANG', None) + if lang: + locale.setlocale(locale.LC_ALL, lang) lang = locale.getlocale()[0] if lang == 'en_US': # MDY format - United States of America