summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2018-01-17 09:06:22 +1100
committerDylan Araps <dylan.araps@gmail.com>2018-01-17 09:06:22 +1100
commit0a71cb7b2b797a64d7798dd539a37d3a0fb7aed7 (patch)
tree049fca1d4ab5b77692679ab0d07c5ca37233a448
parent39ca55d03b7be499f15ed5edb876272ecc2ec756 (diff)
alpha: Store alpha value in scheme file. Fixes #120
-rw-r--r--pywal/__main__.py6
-rw-r--r--pywal/colors.py7
-rw-r--r--pywal/export.py1
-rw-r--r--pywal/sequences.py2
-rw-r--r--pywal/templates/colors.json1
-rw-r--r--pywal/util.py2
6 files changed, 13 insertions, 6 deletions
diff --git a/pywal/__main__.py b/pywal/__main__.py
index 5eb5e00..b480412 100644
--- a/pywal/__main__.py
+++ b/pywal/__main__.py
@@ -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
diff --git a/pywal/colors.py b/pywal/colors.py
index 4c7e308..1fa4b0e 100644
--- a/pywal/colors.py
+++ b/pywal/colors.py
@@ -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
diff --git a/pywal/export.py b/pywal/export.py
index 5049db7..665bdf9 100644
--- a/pywal/export.py
+++ b/pywal/export.py
@@ -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()}
diff --git a/pywal/sequences.py b/pywal/sequences.py
index dcc2378..c492d32 100644
--- a/pywal/sequences.py
+++ b/pywal/sequences.py
@@ -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)
diff --git a/pywal/templates/colors.json b/pywal/templates/colors.json
index 5c94bc4..537a534 100644
--- a/pywal/templates/colors.json
+++ b/pywal/templates/colors.json
@@ -1,5 +1,6 @@
{{
"wallpaper": "{wallpaper}",
+ "alpha": "{alpha}",
"special": {{
"background": "{background}",
diff --git a/pywal/util.py b/pywal/util.py
index ad1d9cf..70dca2f 100644
--- a/pywal/util.py
+++ b/pywal/util.py
@@ -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