summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2017-07-23 18:37:05 +1000
committerDylan Araps <dylan.araps@gmail.com>2017-07-23 18:42:54 +1000
commit83a0f6945d08124a1c763151ce4f7f65443414f9 (patch)
tree5cd8b61874d998e11c432d6488e525cec818992a
parent72d0ca4e2f4be7969498b226af4243315f2dff0c (diff)
general: Add -a to support terminal transparency.
-rw-r--r--pywal/__main__.py7
-rw-r--r--pywal/reload.py2
-rw-r--r--pywal/sequences.py5
-rw-r--r--pywal/templates/colors.Xresources5
-rw-r--r--pywal/util.py7
5 files changed, 24 insertions, 2 deletions
diff --git a/pywal/__main__.py b/pywal/__main__.py
index 0af4df6..566ff95 100644
--- a/pywal/__main__.py
+++ b/pywal/__main__.py
@@ -29,6 +29,10 @@ def get_args():
description = "wal - Generate colorschemes on the fly"
arg = argparse.ArgumentParser(description=description)
+ arg.add_argument("-a", metavar="\"alpha\"",
+ help="Set terminal background transparency. \
+ *Only works in URxvt*")
+
arg.add_argument("-c", action="store_true",
help="Delete all cached colorschemes.")
@@ -86,6 +90,9 @@ def process_args(args):
if args.r:
reload.colors(args.t)
+ if args.a:
+ util.Color.alpha_num = args.a
+
if args.i:
image_file = image.get(args.i)
colors_plain = colors.get(image_file, notify=not args.q)
diff --git a/pywal/reload.py b/pywal/reload.py
index 12769bf..1f5c31c 100644
--- a/pywal/reload.py
+++ b/pywal/reload.py
@@ -48,7 +48,7 @@ def colors(vte, cache_dir=__cache_dir__):
# If vte mode was used, remove the unsupported sequence.
if vte:
- sequences = re.sub(r"\]708;\#.{6}", "", sequences)
+ sequences = re.sub(r"\]708;(\[..\])?\#.{6}", "", sequences)
print(sequences, end="")
diff --git a/pywal/sequences.py b/pywal/sequences.py
index 77eace3..4f14234 100644
--- a/pywal/sequences.py
+++ b/pywal/sequences.py
@@ -9,6 +9,11 @@ from . import util
def set_special(index, color):
"""Convert a hex color to a special sequence."""
+ alpha = util.Color.alpha_num
+
+ if index in [11, 708] and alpha != 100:
+ return f"\033]{index};[{alpha}]{color}\007"
+
return f"\033]{index};{color}\007"
diff --git a/pywal/templates/colors.Xresources b/pywal/templates/colors.Xresources
index f8c7b60..9539ca6 100644
--- a/pywal/templates/colors.Xresources
+++ b/pywal/templates/colors.Xresources
@@ -2,7 +2,7 @@
! Generated by 'wal'
URxvt*foreground: {foreground}
XTerm*foreground: {foreground}
-URxvt*background: {background}
+URxvt*background: {background.alpha}
XTerm*background: {background}
URxvt*cursorColor: {cursor}
XTerm*cursorColor: {cursor}
@@ -60,3 +60,6 @@ XClock*minorColor: rgba:{color15.xrgba}
XClock*hourColor: rgba:{color15.xrgba}
XClock*minuteColor: rgba:{color15.xrgba}
XClock*secondColor: rgba:{color15.xrgba}
+
+! Set depth to make transparency work.
+URxvt*depth: 32
diff --git a/pywal/util.py b/pywal/util.py
index 1df3c9f..25a36a4 100644
--- a/pywal/util.py
+++ b/pywal/util.py
@@ -9,6 +9,8 @@ import subprocess
class Color:
"""Color formats."""
+ alpha_num = 100
+
def __init__(self, hex_color):
self.hex_color = hex_color
@@ -25,6 +27,11 @@ class Color:
"""Convert a hex color to xrdb rgba."""
return hex_to_xrgba(self.hex_color)
+ @property
+ def alpha(self):
+ """Add URxvt alpha value to color."""
+ return f"[{self.alpha_num}]{self.hex_color}"
+
def set_grey(colors):
"""Set a grey color based on the brightness