Aargs: Added --vte to fix artifacts in VTE terminals.

This commit is contained in:
Dylan Araps 2019-01-11 07:47:02 +02:00
parent 669836b9e9
commit 614c1ab44a
2 changed files with 12 additions and 5 deletions

View File

@ -59,6 +59,9 @@ def get_args():
arg.add_argument("--preview", action="store_true",
help="Print the current color palette.")
arg.add_argument("--vte", action="store_true",
help="Fix text-artifacts printed in VTE terminals.")
arg.add_argument("-c", action="store_true",
help="Delete all cached colorschemes.")
@ -174,7 +177,7 @@ def parse_args(parser):
if not args.n:
wallpaper.change(colors_plain["wallpaper"])
sequences.send(colors_plain, to_send=not args.s)
sequences.send(colors_plain, to_send=not args.s, vte_fix=args.vte)
if sys.stdout.isatty():
colors.palette()

View File

@ -35,7 +35,7 @@ def set_iterm_tab_color(color):
"\033]6;1;bg;blue;brightness;%s\a") % (*util.hex_to_rgb(color),)
def create_sequences(colors):
def create_sequences(colors, vte_fix=False):
"""Create the escape sequences."""
alpha = colors["alpha"]
@ -54,18 +54,22 @@ def create_sequences(colors):
set_special(13, colors["special"]["foreground"], "l"),
set_special(17, colors["special"]["foreground"], "l"),
set_special(19, colors["special"]["background"], "l"),
set_special(708, colors["special"]["background"], "l", alpha),
set_color(232, colors["special"]["background"]),
set_color(256, colors["special"]["foreground"])
])
if not vte_fix:
sequences.extend(
set_special(708, colors["special"]["background"], "l", alpha)
)
if OS == "Darwin":
sequences += set_iterm_tab_color(colors["special"]["background"])
return "".join(sequences)
def send(colors, cache_dir=CACHE_DIR, to_send=True):
def send(colors, cache_dir=CACHE_DIR, to_send=True, vte_fix=False):
"""Send colors to all open terminals."""
if OS == "Darwin":
tty_pattern = "/dev/ttys00[0-9]*"
@ -73,7 +77,7 @@ def send(colors, cache_dir=CACHE_DIR, to_send=True):
else:
tty_pattern = "/dev/pts/[0-9]*"
sequences = create_sequences(colors)
sequences = create_sequences(colors, vte_fix)
# Writing to "/dev/pts/[0-9] lets you send data to open terminals.
if to_send: