mirror of
https://github.com/dylanaraps/pywal.git
synced 2024-11-25 17:33:09 +01:00
alpha: Store alpha value in scheme file. Fixes #120
This commit is contained in:
parent
39ca55d03b
commit
0a71cb7b2b
@ -107,9 +107,6 @@ def process_args(args):
|
||||
scheme_dir = os.path.join(CACHE_DIR, "schemes")
|
||||
shutil.rmtree(scheme_dir, ignore_errors=True)
|
||||
|
||||
if args.a:
|
||||
util.Color.alpha_num = args.a
|
||||
|
||||
if args.R:
|
||||
image_file = os.path.join(CACHE_DIR, "wal")
|
||||
|
||||
@ -126,6 +123,9 @@ def process_args(args):
|
||||
if args.f:
|
||||
colors_plain = colors.file(args.f)
|
||||
|
||||
if args.a:
|
||||
util.Color.alpha_num = args.a
|
||||
|
||||
if args.b:
|
||||
args.b = "#%s" % (args.b.strip("#"))
|
||||
colors_plain["special"]["background"] = args.b
|
||||
|
@ -70,7 +70,8 @@ def create_palette(img, colors):
|
||||
raw_colors[8] = util.darken_color(raw_colors[7], 0.30)
|
||||
raw_colors[15] = util.blend_color(raw_colors[15], "#EEEEEE")
|
||||
|
||||
colors = {"wallpaper": img, "special": {}, "colors": {}}
|
||||
colors = {"wallpaper": img, "alpha": util.Color.alpha_num,
|
||||
"special": {}, "colors": {}}
|
||||
colors["special"]["background"] = raw_colors[0]
|
||||
colors["special"]["foreground"] = raw_colors[15]
|
||||
colors["special"]["cursor"] = raw_colors[15]
|
||||
@ -90,6 +91,7 @@ def get(img, cache_dir=CACHE_DIR,
|
||||
|
||||
if os.path.isfile(cache_file):
|
||||
colors = util.read_file_json(cache_file)
|
||||
util.Color.alpha_num = colors["alpha"]
|
||||
print("colors: Found cached colorscheme.")
|
||||
|
||||
else:
|
||||
@ -111,4 +113,7 @@ def file(input_file):
|
||||
if "wallpaper" not in data:
|
||||
data["wallpaper"] = "None"
|
||||
|
||||
if "alpha" not in data:
|
||||
data["alpha"] = 100
|
||||
|
||||
return data
|
||||
|
@ -20,6 +20,7 @@ def flatten_colors(colors):
|
||||
"""Prepare colors to be exported.
|
||||
Flatten dicts and convert colors to util.Color()"""
|
||||
all_colors = {"wallpaper": colors["wallpaper"],
|
||||
"alpha": colors["alpha"],
|
||||
**colors["special"],
|
||||
**colors["colors"]}
|
||||
return {k: util.Color(v) for k, v in all_colors.items()}
|
||||
|
@ -15,7 +15,7 @@ def set_special(index, color, iterm_name="h"):
|
||||
if OS == "Darwin":
|
||||
return "\033]P%s%s\033\\" % (iterm_name, color.strip("#"))
|
||||
|
||||
if index in [11, 708] and alpha != 100:
|
||||
if index in [11, 708] and alpha != "100":
|
||||
return "\033]%s;[%s]%s\033\\" % (index, alpha, color)
|
||||
|
||||
return "\033]%s;%s\033\\" % (index, color)
|
||||
|
@ -1,5 +1,6 @@
|
||||
{{
|
||||
"wallpaper": "{wallpaper}",
|
||||
"alpha": "{alpha}",
|
||||
|
||||
"special": {{
|
||||
"background": "{background}",
|
||||
|
@ -9,7 +9,7 @@ import subprocess
|
||||
|
||||
class Color:
|
||||
"""Color formats."""
|
||||
alpha_num = 100
|
||||
alpha_num = "100"
|
||||
|
||||
def __init__(self, hex_color):
|
||||
self.hex_color = hex_color
|
||||
|
Loading…
Reference in New Issue
Block a user