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.
This commit is contained in:
enkore 2013-02-23 20:41:42 +01:00
parent ebe3d718e3
commit dd7b5ef346
2 changed files with 20 additions and 5 deletions

View File

@ -109,6 +109,10 @@ class Module(SettingsBase):
def registered(self, status_handler): def registered(self, status_handler):
"""Called when this module is registered with a 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): class AsyncModule(Module):
def registered(self, status_handler): def registered(self, status_handler):
self.thread = Thread(target=self.mainloop) self.thread = Thread(target=self.mainloop)
@ -298,5 +302,5 @@ class i3pystatus:
def run(self): def run(self):
for j in JSONIO(self.io).read(): for j in JSONIO(self.io).read():
for module in self.modules: for module in self.modules:
j.insert(module.position, module.output) module.inject(j)
I3statusHandler = i3pystatus I3statusHandler = i3pystatus

View File

@ -14,10 +14,21 @@ class Clock(IntervalModule):
format = None format = None
def init(self): def init(self):
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) lang = os.environ.get('LANG', None)
if lang: if lang:
locale.setlocale(locale.LC_ALL, lang) locale.setlocale(locale.LC_ALL, lang)
if self.format is None:
lang = locale.getlocale()[0] lang = locale.getlocale()[0]
if lang == 'en_US': if lang == 'en_US':
# MDY format - United States of America # MDY format - United States of America