diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-06-26 12:25:58 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-06-26 12:25:58 +1000 |
| commit | b47dcb1e0df2b6ee39a18e536fa66530fe5066d4 (patch) | |
| tree | 052892079eb35f07cfc1b52ff903e9089b064b4d /pywal/export.py | |
| parent | 3d1627f3c772fef0e24aa1303ff0982b8a7242ed (diff) | |
General: Generalise functions.
Diffstat (limited to 'pywal/export.py')
| -rw-r--r-- | pywal/export.py | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/pywal/export.py b/pywal/export.py index dfb774c..a153f7f 100644 --- a/pywal/export.py +++ b/pywal/export.py @@ -1,6 +1,8 @@ """ Export colors in various formats. """ +import pathlib +import re import shutil import subprocess @@ -15,6 +17,35 @@ def save_colors(colors, export_file, message): print(f"export: exported {message}.") +def reload_colors(vte): + """Reload colors.""" + sequence_file = pathlib.Path(s.CACHE_DIR / "sequences") + + if sequence_file.is_file(): + sequences = "".join(util.read_file(sequence_file)) + + # If vte mode was used, remove the problem sequence. + if vte: + sequences = re.sub(r"\]708;\#.{6}", "", sequences) + + # Make the terminal interpret escape sequences. + print(util.fix_escape(sequences), end="") + + exit(0) + + +def reload_xrdb(export_file): + """Merge the colors into the X db so new terminals use them.""" + if shutil.which("xrdb"): + subprocess.call(["xrdb", "-merge", s.CACHE_DIR / export_file]) + + +def reload_i3(): + """Reload i3 colors.""" + if shutil.which("i3-msg"): + util.disown("i3-msg", "reload") + + def export_rofi(colors): """Append rofi colors to the x_colors list.""" s.ColorType.xrdb.append(f"rofi.color-window: {colors[0]}, " @@ -36,18 +67,6 @@ def export_emacs(colors): s.ColorType.xrdb.append(f"emacs*foreground: {colors[15]}") -def reload_xrdb(export_file): - """Merge the colors into the X db so new terminals use them.""" - if shutil.which("xrdb"): - subprocess.call(["xrdb", "-merge", s.CACHE_DIR / export_file]) - - -def reload_i3(): - """Reload i3 colors.""" - if shutil.which("i3-msg"): - util.disown("i3-msg", "reload") - - def export_colors(colors): """Export colors in various formats.""" save_colors(s.ColorType.plain, "colors", "plain hex colors") |
