summaryrefslogtreecommitdiff
path: root/pywal/reload.py
diff options
context:
space:
mode:
authorDylan Araps <dylanaraps@users.noreply.github.com>2017-07-23 15:37:14 +1000
committerGitHub <noreply@github.com>2017-07-23 15:37:14 +1000
commit0c1d76e2b3611b541316dc8d7eb67f18cec5e7f2 (patch)
treeaaf8141c62789dcfc4f72af24ae96df71459a084 /pywal/reload.py
parent9c871ec567504c2566c4ce9f3d382f544cb62b57 (diff)
parent07b8ad8e0d97f54277c2e744f745ba3e47d0e53c (diff)
Merge pull request #52 from dylanaraps/api
api: Start work on a proper api.
Diffstat (limited to 'pywal/reload.py')
-rw-r--r--pywal/reload.py41
1 files changed, 31 insertions, 10 deletions
diff --git a/pywal/reload.py b/pywal/reload.py
index 5cc7307..12769bf 100644
--- a/pywal/reload.py
+++ b/pywal/reload.py
@@ -1,34 +1,55 @@
"""
Reload programs.
"""
+import re
import shutil
import subprocess
-from pywal.settings import CACHE_DIR
-from pywal import util
+from .settings import __cache_dir__
+from . import util
-def reload_xrdb():
+def xrdb(xrdb_file=None):
"""Merge the colors into the X db so new terminals use them."""
+ xrdb_file = xrdb_file or __cache_dir__ / "colors.Xresources"
+
if shutil.which("xrdb"):
- subprocess.call(["xrdb", "-merge", CACHE_DIR / "colors.Xresources"])
+ subprocess.call(["xrdb", "-merge", xrdb_file],
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL)
-def reload_i3():
+def i3():
"""Reload i3 colors."""
if shutil.which("i3-msg"):
util.disown("i3-msg", "reload")
-def reload_polybar():
+def polybar():
"""Reload polybar colors."""
if shutil.which("polybar"):
util.disown("pkill", "-USR1", "polybar")
-def reload_env():
+def env(xrdb_file=None):
"""Reload environment."""
- reload_xrdb()
- reload_i3()
- reload_polybar()
+ xrdb(xrdb_file)
+ i3()
+ polybar()
print("reload: Reloaded environment.")
+
+
+def colors(vte, cache_dir=__cache_dir__):
+ """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)