mirror of
https://github.com/dylanaraps/pywal.git
synced 2024-11-29 11:24:03 +01:00
colors: Use json for all wal generated colors.
This commit is contained in:
parent
8a908de48c
commit
3b6475be1a
@ -90,7 +90,6 @@ def process_args(args):
|
||||
|
||||
# Create a list of hex colors.
|
||||
colors_plain = gen_colors.get_colors(image, args.q)
|
||||
# colors_plain[8] = set_colors.set_grey(colors_plain)
|
||||
|
||||
if not args.n:
|
||||
wallpaper.set_wallpaper(image)
|
||||
|
@ -9,6 +9,7 @@ import shutil
|
||||
import subprocess
|
||||
|
||||
from pywal.settings import CACHE_DIR, COLOR_COUNT
|
||||
from pywal import set_colors
|
||||
from pywal import util
|
||||
|
||||
|
||||
@ -96,9 +97,10 @@ def get_colors(img, quiet):
|
||||
|
||||
# Cache the sequences file.
|
||||
cache_file = pathlib.Path(CACHE_DIR / "schemes" / img.replace("/", "_"))
|
||||
cache_file = pathlib.Path(cache_file.with_suffix(".json"))
|
||||
|
||||
if cache_file.is_file():
|
||||
colors = util.read_file(cache_file)
|
||||
colors = util.read_file_json(cache_file)
|
||||
print("colors: Found cached colorscheme.")
|
||||
|
||||
else:
|
||||
@ -111,7 +113,7 @@ def get_colors(img, quiet):
|
||||
colors = sort_colors(colors)
|
||||
|
||||
# Cache the colorscheme.
|
||||
util.save_file("\n".join(colors), cache_file)
|
||||
util.save_file_json(colors, cache_file)
|
||||
|
||||
print("colors: Generated colorscheme")
|
||||
if not quiet:
|
||||
@ -135,6 +137,9 @@ def sort_colors(colors):
|
||||
[colors_hex.update({f"color{index}": color}) # pylint: disable=W0106
|
||||
for index, color in enumerate(raw_colors)]
|
||||
|
||||
# Color 8
|
||||
colors_hex["color8"] = set_colors.set_grey(raw_colors)
|
||||
|
||||
# Add the colors to a dict.
|
||||
colors = {}
|
||||
colors["special"] = colors_special
|
||||
|
@ -27,6 +27,12 @@ def save_file(colors, export_file):
|
||||
file.write(colors)
|
||||
|
||||
|
||||
def save_file_json(colors, export_file):
|
||||
"""Write the colors to a json file."""
|
||||
with open(export_file, "w") as file:
|
||||
json.dump(colors, file, indent=4)
|
||||
|
||||
|
||||
def create_dir(directory):
|
||||
"""Alias to create the cache dir."""
|
||||
pathlib.Path(directory).mkdir(parents=True, exist_ok=True)
|
||||
|
Loading…
Reference in New Issue
Block a user