mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-08 15:09:38 +01:00
general: Add -a to support terminal transparency.
This commit is contained in:
parent
72d0ca4e2f
commit
83a0f6945d
@ -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)
|
||||
|
@ -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="")
|
||||
|
||||
|
@ -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"
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user