summaryrefslogtreecommitdiff
path: root/pywal/reload.py
blob: 77a496af5a54348a1e0688f9defd51a86cacf277 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
Reload programs.
"""
import shutil
import subprocess

from pywal import util


def reload_xrdb(cache_dir):
    """Merge the colors into the X db so new terminals use them."""
    if shutil.which("xrdb"):
        subprocess.call(["xrdb", "-merge", cache_dir / "colors.Xresources"])


def reload_i3():
    """Reload i3 colors."""
    if shutil.which("i3-msg"):
        util.disown("i3-msg", "reload")


def reload_polybar():
    """Reload polybar colors."""
    if shutil.which("polybar"):
        util.disown("pkill", "-USR1", "polybar")


def reload_env(cache_dir):
    """Reload environment."""
    reload_xrdb(cache_dir)
    reload_i3()
    reload_polybar()
    print("reload: Reloaded environment.")