mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-23 22:38:36 +01:00
general: Add -a to support terminal transparency.
This commit is contained in:
parent
38744ecf3e
commit
416904b29b
@ -29,6 +29,10 @@ def get_args():
|
|||||||
description = "wal - Generate colorschemes on the fly"
|
description = "wal - Generate colorschemes on the fly"
|
||||||
arg = argparse.ArgumentParser(description=description)
|
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",
|
arg.add_argument("-c", action="store_true",
|
||||||
help="Delete all cached colorschemes.")
|
help="Delete all cached colorschemes.")
|
||||||
|
|
||||||
@ -86,6 +90,9 @@ def process_args(args):
|
|||||||
if args.r:
|
if args.r:
|
||||||
reload.colors(args.t)
|
reload.colors(args.t)
|
||||||
|
|
||||||
|
if args.a:
|
||||||
|
util.Color.alpha_num = args.a
|
||||||
|
|
||||||
if args.i:
|
if args.i:
|
||||||
image_file = image.get(args.i)
|
image_file = image.get(args.i)
|
||||||
colors_plain = colors.get(image_file, notify=not args.q)
|
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 mode was used, remove the unsupported sequence.
|
||||||
if vte:
|
if vte:
|
||||||
sequences = re.sub(r"\]708;\#.{6}", "", sequences)
|
sequences = re.sub(r"\]708;(\[..\])?\#.{6}", "", sequences)
|
||||||
|
|
||||||
print(sequences, end="")
|
print(sequences, end="")
|
||||||
|
|
||||||
|
@ -9,6 +9,11 @@ from . import util
|
|||||||
|
|
||||||
def set_special(index, color):
|
def set_special(index, color):
|
||||||
"""Convert a hex color to a special sequence."""
|
"""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"
|
return f"\033]{index};{color}\007"
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
! Generated by 'wal'
|
! Generated by 'wal'
|
||||||
URxvt*foreground: {foreground}
|
URxvt*foreground: {foreground}
|
||||||
XTerm*foreground: {foreground}
|
XTerm*foreground: {foreground}
|
||||||
URxvt*background: {background}
|
URxvt*background: {background.alpha}
|
||||||
XTerm*background: {background}
|
XTerm*background: {background}
|
||||||
URxvt*cursorColor: {cursor}
|
URxvt*cursorColor: {cursor}
|
||||||
XTerm*cursorColor: {cursor}
|
XTerm*cursorColor: {cursor}
|
||||||
@ -60,3 +60,6 @@ XClock*minorColor: rgba:{color15.xrgba}
|
|||||||
XClock*hourColor: rgba:{color15.xrgba}
|
XClock*hourColor: rgba:{color15.xrgba}
|
||||||
XClock*minuteColor: rgba:{color15.xrgba}
|
XClock*minuteColor: rgba:{color15.xrgba}
|
||||||
XClock*secondColor: 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:
|
class Color:
|
||||||
"""Color formats."""
|
"""Color formats."""
|
||||||
|
alpha_num = 100
|
||||||
|
|
||||||
def __init__(self, hex_color):
|
def __init__(self, hex_color):
|
||||||
self.hex_color = hex_color
|
self.hex_color = hex_color
|
||||||
|
|
||||||
@ -25,6 +27,11 @@ class Color:
|
|||||||
"""Convert a hex color to xrdb rgba."""
|
"""Convert a hex color to xrdb rgba."""
|
||||||
return hex_to_xrgba(self.hex_color)
|
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):
|
def set_grey(colors):
|
||||||
"""Set a grey color based on the brightness
|
"""Set a grey color based on the brightness
|
||||||
|
Loading…
Reference in New Issue
Block a user