diff options
| author | Dylan Araps <dylanaraps@users.noreply.github.com> | 2017-07-23 15:37:14 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-23 15:37:14 +1000 |
| commit | 0c1d76e2b3611b541316dc8d7eb67f18cec5e7f2 (patch) | |
| tree | aaf8141c62789dcfc4f72af24ae96df71459a084 /pywal/sequences.py | |
| parent | 9c871ec567504c2566c4ce9f3d382f544cb62b57 (diff) | |
| parent | 07b8ad8e0d97f54277c2e744f745ba3e47d0e53c (diff) | |
Merge pull request #52 from dylanaraps/api
api: Start work on a proper api.
Diffstat (limited to 'pywal/sequences.py')
| -rw-r--r-- | pywal/sequences.py | 36 |
1 files changed, 9 insertions, 27 deletions
diff --git a/pywal/sequences.py b/pywal/sequences.py index 858c381..77eace3 100644 --- a/pywal/sequences.py +++ b/pywal/sequences.py @@ -2,10 +2,9 @@ Send sequences to all open terminals. """ import os -import re -from pywal.settings import CACHE_DIR -from pywal import util +from .settings import __cache_dir__ +from . import util def set_special(index, color): @@ -18,14 +17,14 @@ def set_color(index, color): return f"\033]4;{index};{color}\007" -def send_sequences(colors, vte): +def send(colors, vte, cache_dir=__cache_dir__): """Send colors to all open terminals.""" # Colors 0-15. sequences = [set_color(num, color) for num, color in enumerate(colors["colors"].values())] # Special colors. - # http://pod.tst.eu/http://cvs.schmorp.de/rxvt-unicode/doc/rxvt.7.pod#XTerm_Operating_System_Commands + # Source: https://goo.gl/KcoQgP # 10 = foreground, 11 = background, 12 = cursor foregound # 13 = mouse foreground sequences.append(set_special(10, colors["special"]["foreground"])) @@ -33,7 +32,7 @@ def send_sequences(colors, vte): sequences.append(set_special(12, colors["special"]["cursor"])) sequences.append(set_special(13, colors["special"]["cursor"])) - # Set a blank color that isn"t affected by bold highlighting. + # Set a blank color that isn't affected by bold highlighting. # Used in wal.vim's airline theme. sequences.append(set_color(66, colors["special"]["background"])) @@ -41,29 +40,12 @@ def send_sequences(colors, vte): if not vte: sequences.append(set_special(708, colors["special"]["background"])) - # Get the list of terminals. terminals = [f"/dev/pts/{term}" for term in os.listdir("/dev/pts/") if len(term) < 4] - terminals.append(CACHE_DIR / "sequences") + terminals.append(cache_dir / "sequences") - # Send the sequences to all open terminals. - # pylint: disable=W0106 - [util.save_file("".join(sequences), term) for term in terminals] + # Writing to "/dev/pts/[0-9] lets you send data to open terminals. + for term in terminals: + util.save_file("".join(sequences), term) print("colors: Set terminal colors") - - -def reload_colors(vte): - """Reload the current scheme.""" - sequence_file = CACHE_DIR / "sequences" - - if sequence_file.is_file(): - sequences = "".join(util.read_file(sequence_file)) - - # If vte mode was used, remove the unsupported sequence. - if vte: - sequences = re.sub(r"\]708;\#.{6}", "", sequences) - - print(sequences, end="") - - exit(0) |
