summaryrefslogtreecommitdiff
path: root/pywal
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2018-03-16 08:47:53 +1100
committerDylan Araps <dylan.araps@gmail.com>2018-03-16 08:47:53 +1100
commit7db89a390728944637fc4c3517894f3d22543447 (patch)
treea0bce598f6197072a38b8b0fd449bf6544eb052b /pywal
parente76887915fa8ca4bab27309da663f438a56fa8cb (diff)
themes: Allow local themes
Diffstat (limited to 'pywal')
-rw-r--r--pywal/__main__.py5
-rw-r--r--pywal/colors.py16
2 files changed, 15 insertions, 6 deletions
diff --git a/pywal/__main__.py b/pywal/__main__.py
index f9bd2a2..05f96e7 100644
--- a/pywal/__main__.py
+++ b/pywal/__main__.py
@@ -14,7 +14,7 @@ import os
import shutil
import sys
-from .settings import __version__, CACHE_DIR, MODULE_DIR
+from .settings import __version__, CACHE_DIR, MODULE_DIR, CONF_DIR
from . import colors
from . import export
from . import image
@@ -125,7 +125,8 @@ def process_args(args):
colors_plain = colors.get(image_file, light=args.l)
if args.f == "list_themes":
- themes = os.listdir(os.path.join(MODULE_DIR, "colorschemes"))
+ themes = os.listdir(os.path.join(CONF_DIR, "colorschemes"))
+ themes += os.listdir(os.path.join(MODULE_DIR, "colorschemes"))
print("Themes:",
", ".join([theme.replace(".json", "") for theme in themes]))
diff --git a/pywal/colors.py b/pywal/colors.py
index 1619e40..664dd4b 100644
--- a/pywal/colors.py
+++ b/pywal/colors.py
@@ -7,7 +7,8 @@ import shutil
import subprocess
import sys
-from .settings import CACHE_DIR, COLOR_COUNT, MODULE_DIR, __cache_version__
+from .settings import CACHE_DIR, COLOR_COUNT, MODULE_DIR, \
+ CONF_DIR, __cache_version__
from . import util
@@ -144,10 +145,17 @@ def terminal_sexy_to_wal(data):
def file(input_file):
"""Import colorscheme from json file."""
- theme_file = os.path.join(MODULE_DIR, "colorschemes",
- ".".join((input_file, "json")))
+ theme_file = ".".join((input_file, "json"))
+ user_theme_dir = os.path.join(CONF_DIR, "colorschemes")
+ user_theme_file = os.path.join(user_theme_dir, theme_file)
+ theme_file = os.path.join(MODULE_DIR, "colorschemes", theme_file)
- if os.path.isfile(theme_file):
+ util.create_dir(user_theme_dir)
+
+ if os.path.isfile(user_theme_file):
+ input_file = user_theme_file
+
+ elif os.path.isfile(theme_file):
input_file = theme_file
if os.path.isfile(input_file):