define custom segments

This commit is contained in:
Artem Werner 2018-05-30 14:09:09 +02:00
parent 73b01d6597
commit bc9aea89c5

View file

@ -8,6 +8,7 @@ import importlib
import json
from .utils import warn, py3, import_file
import re
import imp
def _current_dir():
@ -216,7 +217,10 @@ def main():
powerline = Powerline(args, config, theme)
segments = []
for seg_name in config["segments"]:
mod = importlib.import_module("powerline_shell.segments." + seg_name)
if seg_name.endswith(".py") and os.path.exists(seg_name):
mod = imp.load_source("powerline_shell.segments." + os.path.splitext(os.path.basename(seg_name))[0], seg_name)
else:
mod = importlib.import_module("powerline_shell.segments." + seg_name)
segment = getattr(mod, "Segment")(powerline)
segment.start()
segments.append(segment)