mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-26 07:49:17 +01:00
Merge pull request #143 from dylanaraps/reload
reload: Remove -r and -t (NO MORE VTE JUNK)
This commit is contained in:
commit
e68495b0a5
@ -56,14 +56,14 @@ def get_args(args):
|
|||||||
don't display notifications.")
|
don't display notifications.")
|
||||||
|
|
||||||
arg.add_argument("-r", action="store_true",
|
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",
|
arg.add_argument("-R", action="store_true",
|
||||||
help="Restore previous colorscheme.")
|
help="Restore previous colorscheme.")
|
||||||
|
|
||||||
arg.add_argument("-t", action="store_true",
|
arg.add_argument("-t", action="store_false",
|
||||||
help="Fix artifacts in VTE Terminals. \
|
help="Deprecated: Does nothing and is no longer needed.")
|
||||||
(Termite, xfce4-terminal)")
|
|
||||||
|
|
||||||
arg.add_argument("-v", action="store_true",
|
arg.add_argument("-v", action="store_true",
|
||||||
help="Print \"wal\" version.")
|
help="Print \"wal\" version.")
|
||||||
@ -90,6 +90,10 @@ def process_args(args):
|
|||||||
print("wal", __version__)
|
print("wal", __version__)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
if args.r:
|
||||||
|
print("Deprecated: Use (cat ~/.cache/wal/sequences &) instead.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if args.q:
|
if args.q:
|
||||||
sys.stdout = sys.stderr = open(os.devnull, "w")
|
sys.stdout = sys.stderr = open(os.devnull, "w")
|
||||||
|
|
||||||
@ -97,10 +101,6 @@ def process_args(args):
|
|||||||
scheme_dir = os.path.join(CACHE_DIR, "schemes")
|
scheme_dir = os.path.join(CACHE_DIR, "schemes")
|
||||||
shutil.rmtree(scheme_dir, ignore_errors=True)
|
shutil.rmtree(scheme_dir, ignore_errors=True)
|
||||||
|
|
||||||
if args.r:
|
|
||||||
reload.colors(args.t)
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
if args.a:
|
if args.a:
|
||||||
util.Color.alpha_num = args.a
|
util.Color.alpha_num = args.a
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ def process_args(args):
|
|||||||
colors_plain["colors"]["color0"] = args.b
|
colors_plain["colors"]["color0"] = args.b
|
||||||
|
|
||||||
if args.i or args.f:
|
if args.i or args.f:
|
||||||
sequences.send(colors_plain, args.t)
|
sequences.send(colors_plain)
|
||||||
|
|
||||||
if not args.n:
|
if not args.n:
|
||||||
wallpaper.change(colors_plain["wallpaper"])
|
wallpaper.change(colors_plain["wallpaper"])
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
Reload programs.
|
Reload programs.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@ -65,17 +64,3 @@ def env(xrdb_file=None):
|
|||||||
sway()
|
sway()
|
||||||
polybar()
|
polybar()
|
||||||
print("reload: Reloaded environment.")
|
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)
|
""" % (red, green, blue)
|
||||||
|
|
||||||
|
|
||||||
def create_sequences(colors, vte):
|
def create_sequences(colors):
|
||||||
"""Create the escape sequences."""
|
"""Create the escape sequences."""
|
||||||
# Colors 0-15.
|
# Colors 0-15.
|
||||||
sequences = [set_color(index, colors["colors"]["color%s" % index])
|
sequences = [set_color(index, colors["colors"]["color%s" % index])
|
||||||
for index in range(16)]
|
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.
|
# Special colors.
|
||||||
# Source: https://goo.gl/KcoQgP
|
# Source: https://goo.gl/KcoQgP
|
||||||
# 10 = foreground, 11 = background, 12 = cursor foregound
|
# 10 = foreground, 11 = background, 12 = cursor foregound
|
||||||
@ -61,12 +57,23 @@ def create_sequences(colors, vte):
|
|||||||
if OS == "Darwin":
|
if OS == "Darwin":
|
||||||
sequences += set_iterm_tab_color(colors["special"]["background"])
|
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)
|
return "".join(sequences)
|
||||||
|
|
||||||
|
|
||||||
def send(colors, vte, cache_dir=CACHE_DIR):
|
def send(colors, cache_dir=CACHE_DIR):
|
||||||
"""Send colors to all open terminals."""
|
"""Send colors to all open terminals."""
|
||||||
sequences = create_sequences(colors, vte)
|
sequences = create_sequences(colors)
|
||||||
|
|
||||||
if OS == "Darwin":
|
if OS == "Darwin":
|
||||||
tty_pattern = "/dev/ttys00[0-9]*"
|
tty_pattern = "/dev/ttys00[0-9]*"
|
||||||
|
Loading…
Reference in New Issue
Block a user