summaryrefslogtreecommitdiff
path: root/pywal/theme.py
diff options
context:
space:
mode:
authoraschey <aschey13@gmail.com>2019-12-01 14:28:23 -0600
committeraschey <aschey13@gmail.com>2019-12-01 14:28:23 -0600
commit85526b657107c8fa08861a6c6ef3790c5bc14fac (patch)
treee1881785495c3e6fc5b5fa1c7b23b26737072090 /pywal/theme.py
parent788533e5c20132c727e2f287dce6ada64ebd5872 (diff)
parentc18f4014f969504deaeb692aa88660ee4cb10f3f (diff)
Merge branch 'master' into theme_save
Diffstat (limited to 'pywal/theme.py')
-rw-r--r--pywal/theme.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/pywal/theme.py b/pywal/theme.py
index 62695b5..9dc4f13 100644
--- a/pywal/theme.py
+++ b/pywal/theme.py
@@ -6,7 +6,7 @@ import os
import random
import sys
-from .settings import CONF_DIR, MODULE_DIR
+from .settings import CACHE_DIR, CONF_DIR, MODULE_DIR
from . import util
@@ -19,15 +19,24 @@ def list_out():
user_themes = [theme.name.replace(".json", "")
for theme in list_themes_user()]
+ try:
+ last_used_theme = util.read_file(os.path.join(
+ CACHE_DIR, "last_used_theme"))[0].replace(".json", "")
+ except FileNotFoundError:
+ last_used_theme = ""
+
if user_themes:
print("\033[1;32mUser Themes\033[0m:")
- print(" -", "\n - ".join(sorted(user_themes)))
+ print(" -", "\n - ".join(t + " (last used)" if t == last_used_theme
+ else t for t in sorted(user_themes)))
print("\033[1;32mDark Themes\033[0m:")
- print(" -", "\n - ".join(sorted(dark_themes)))
+ print(" -", "\n - ".join(t + " (last used)" if t == last_used_theme else t
+ for t in sorted(dark_themes)))
print("\033[1;32mLight Themes\033[0m:")
- print(" -", "\n - ".join(sorted(ligh_themes)))
+ print(" -", "\n - ".join(t + " (last used)" if t == last_used_theme else t
+ for t in sorted(ligh_themes)))
print("\033[1;32mExtra\033[0m:")
print(" - random (select a random dark theme)")
@@ -127,6 +136,8 @@ def file(input_file, light=False):
if os.path.isfile(theme_file):
logging.info("Set theme to \033[1;37m%s\033[0m.",
os.path.basename(theme_file))
+ util.save_file(os.path.basename(theme_file),
+ os.path.join(CACHE_DIR, "last_used_theme"))
return parse(theme_file)
logging.error("No %s colorscheme file found.", bri)