Make sure powerline class knows that it will use UTF-8

This commit is contained in:
ZyX 2015-01-25 17:02:54 +03:00
parent ea9eae676f
commit ff0631c625
1 changed files with 16 additions and 9 deletions

View File

@ -13,6 +13,21 @@ from powerline.lib.monotonic import monotonic
from powerline.lib.encoding import get_unicode_writer
class BarPowerline(Powerline):
get_encoding = staticmethod(lambda: 'utf-8')
def init(self):
super(BarPowerline, self).init(ext='wm', renderer_module='bar')
def render(event=None, data=None, sub=None):
global lock
with lock:
write(powerline.render())
write('\n')
sys.stdout.flush()
if __name__ == '__main__':
parser = ArgumentParser(description='Powerline BAR bindings.')
parser.add_argument(
@ -20,21 +35,13 @@ if __name__ == '__main__':
help='Subscribe for i3 events.'
)
args = parser.parse_args()
powerline = Powerline('wm', renderer_module='bar')
powerline.update_renderer()
powerline = BarPowerline()
interval = 0.5
lock = Lock()
write = get_unicode_writer(encoding='utf-8')
def render(event=None, data=None, sub=None):
global lock
with lock:
write(powerline.render())
write('\n')
sys.stdout.flush()
if args.i3:
import i3
sub = i3.Subscription(render, 'workspace')