diff --git a/powerline_shell/themes/colortest.py b/colortest.py similarity index 100% rename from powerline_shell/themes/colortest.py rename to colortest.py diff --git a/powerline_shell/__init__.py b/powerline_shell/__init__.py index 7d70ebe..46511a0 100644 --- a/powerline_shell/__init__.py +++ b/powerline_shell/__init__.py @@ -6,7 +6,6 @@ import os import sys import importlib import json -from .themes.default import DefaultColor from .utils import warn, py3 @@ -68,10 +67,10 @@ class Powerline(object): 'bare': '%s', } - def __init__(self, args, config, theme=None): + def __init__(self, args, config, theme): self.args = args self.config = config - self.theme = theme or DefaultColor + self.theme = theme self.cwd = get_valid_cwd() mode = config.get("mode", "patched") shell = config.get("shell", "bash") @@ -152,7 +151,11 @@ def main(): with open(config_path) as f: config = json.loads(f.read()) - powerline = Powerline(args, config) + theme_name = config.get("theme", "default") + mod = importlib.import_module("powerline_shell.themes." + theme_name) + theme = getattr(mod, "Color") + + powerline = Powerline(args, config, theme) segments = [] for seg_name in config["segments"]: mod = importlib.import_module("powerline_shell.segments." + seg_name) diff --git a/powerline_shell/themes/basic.py b/powerline_shell/themes/basic.py index 5d07691..efb87cd 100644 --- a/powerline_shell/themes/basic.py +++ b/powerline_shell/themes/basic.py @@ -1,6 +1,8 @@ -# Basic theme which only uses colors in 0-15 range +from .default import DefaultColor + class Color(DefaultColor): + """Basic theme which only uses colors in 0-15 range""" USERNAME_FG = 8 USERNAME_BG = 15 USERNAME_ROOT_BG = 1 diff --git a/powerline_shell/themes/default.py b/powerline_shell/themes/default.py index 6526158..faa0473 100644 --- a/powerline_shell/themes/default.py +++ b/powerline_shell/themes/default.py @@ -1,4 +1,4 @@ -class DefaultColor: +class DefaultColor(object): """ This class should have the default colors for every segment. Please test every new segment with this theme first. diff --git a/powerline_shell/themes/solarized-dark.py b/powerline_shell/themes/solarized_dark.py similarity index 94% rename from powerline_shell/themes/solarized-dark.py rename to powerline_shell/themes/solarized_dark.py index 4e158c8..7e0f2d8 100644 --- a/powerline_shell/themes/solarized-dark.py +++ b/powerline_shell/themes/solarized_dark.py @@ -1,3 +1,6 @@ +from .default import DefaultColor + + class Color(DefaultColor): USERNAME_FG = 15 USERNAME_BG = 4 diff --git a/powerline_shell/themes/washed.py b/powerline_shell/themes/washed.py index 3c455e3..d1f2642 100644 --- a/powerline_shell/themes/washed.py +++ b/powerline_shell/themes/washed.py @@ -1,3 +1,6 @@ +from .default import DefaultColor + + class Color(DefaultColor): USERNAME_FG = 8 USERNAME_BG = 251