mirror of
https://github.com/dylanaraps/pywal.git
synced 2024-11-29 03:13:47 +01:00
Merge branch 'master' of github.com:dylanaraps/pywal
This commit is contained in:
commit
695ae1ffb2
@ -56,14 +56,14 @@ def get_args(args):
|
||||
don't display notifications.")
|
||||
|
||||
arg.add_argument("-r", action="store_true",
|
||||
help="Reload current colorscheme.")
|
||||
help="Deprecated: Use \
|
||||
(cat ~/.cache/wal/sequences &) instead.")
|
||||
|
||||
arg.add_argument("-R", action="store_true",
|
||||
help="Restore previous colorscheme.")
|
||||
|
||||
arg.add_argument("-t", action="store_true",
|
||||
help="Fix artifacts in VTE Terminals. \
|
||||
(Termite, xfce4-terminal)")
|
||||
arg.add_argument("-t", action="store_false",
|
||||
help="Deprecated: Does nothing and is no longer needed.")
|
||||
|
||||
arg.add_argument("-v", action="store_true",
|
||||
help="Print \"wal\" version.")
|
||||
@ -90,6 +90,10 @@ def process_args(args):
|
||||
print("wal", __version__)
|
||||
sys.exit(0)
|
||||
|
||||
if args.r:
|
||||
print("Deprecated: Use (cat ~/.cache/wal/sequences &) instead.")
|
||||
sys.exit(1)
|
||||
|
||||
if args.q:
|
||||
sys.stdout = sys.stderr = open(os.devnull, "w")
|
||||
|
||||
@ -97,10 +101,6 @@ def process_args(args):
|
||||
scheme_dir = os.path.join(CACHE_DIR, "schemes")
|
||||
shutil.rmtree(scheme_dir, ignore_errors=True)
|
||||
|
||||
if args.r:
|
||||
reload.colors(args.t)
|
||||
sys.exit(0)
|
||||
|
||||
if args.a:
|
||||
util.Color.alpha_num = args.a
|
||||
|
||||
@ -125,7 +125,7 @@ def process_args(args):
|
||||
colors_plain["colors"]["color0"] = args.b
|
||||
|
||||
if args.i or args.f:
|
||||
sequences.send(colors_plain, args.t)
|
||||
sequences.send(colors_plain)
|
||||
|
||||
if not args.n:
|
||||
wallpaper.change(colors_plain["wallpaper"])
|
||||
|
@ -2,7 +2,6 @@
|
||||
Reload programs.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
@ -65,17 +64,3 @@ def env(xrdb_file=None):
|
||||
sway()
|
||||
polybar()
|
||||
print("reload: Reloaded environment.")
|
||||
|
||||
|
||||
def colors(vte, cache_dir=CACHE_DIR):
|
||||
"""Reload the current scheme."""
|
||||
sequence_file = os.path.join(cache_dir, "sequences")
|
||||
|
||||
if os.path.isfile(sequence_file):
|
||||
sequences = "".join(util.read_file(sequence_file))
|
||||
|
||||
# If vte mode was used, remove the unsupported sequence.
|
||||
if vte:
|
||||
sequences = re.sub(r"\]708;(\[.{0,3}\])?\#.{6}", "", sequences)
|
||||
|
||||
print(sequences, end="")
|
||||
|
@ -39,16 +39,12 @@ def set_iterm_tab_color(color):
|
||||
""" % (red, green, blue)
|
||||
|
||||
|
||||
def create_sequences(colors, vte):
|
||||
def create_sequences(colors):
|
||||
"""Create the escape sequences."""
|
||||
# Colors 0-15.
|
||||
sequences = [set_color(index, colors["colors"]["color%s" % index])
|
||||
for index in range(16)]
|
||||
|
||||
# This escape sequence doesn"t work in VTE terminals.
|
||||
if not vte:
|
||||
sequences.append(set_special(708, colors["special"]["background"]))
|
||||
|
||||
# Special colors.
|
||||
# Source: https://goo.gl/KcoQgP
|
||||
# 10 = foreground, 11 = background, 12 = cursor foregound
|
||||
@ -61,12 +57,23 @@ def create_sequences(colors, vte):
|
||||
if OS == "Darwin":
|
||||
sequences += set_iterm_tab_color(colors["special"]["background"])
|
||||
|
||||
# This escape sequence doesn't work in VTE terminals and their parsing of
|
||||
# unknown sequences is garbage so we need to use some escape sequence
|
||||
# M A G I C to hide the output.
|
||||
# \0337 # Save cursor position.
|
||||
# \033[1000H # Move the cursor off screen.
|
||||
# \033[8m # Conceal text.
|
||||
# \033]708;#000000\007 # Garbage sequence.
|
||||
# \0338 # Restore cursor position.
|
||||
sequences.append("\0337\033[1000H\033[8m\033]708;%s\007\0338" %
|
||||
colors['special']['background'])
|
||||
|
||||
return "".join(sequences)
|
||||
|
||||
|
||||
def send(colors, vte, cache_dir=CACHE_DIR):
|
||||
def send(colors, cache_dir=CACHE_DIR):
|
||||
"""Send colors to all open terminals."""
|
||||
sequences = create_sequences(colors, vte)
|
||||
sequences = create_sequences(colors)
|
||||
|
||||
if OS == "Darwin":
|
||||
tty_pattern = "/dev/ttys00[0-9]*"
|
||||
|
Loading…
Reference in New Issue
Block a user