"""
Reload programs.
"""
import shutil
import subprocess

from pywal.settings import CACHE_DIR
from pywal import util


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


def reload_xrdb():
    """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_env():
    """Reload environment programs."""
    reload_i3()
    reload_xrdb()
    print("reload: Reloaded environment.")

@@ -117,126 +117,8 @@
 l%0A%0A%0A
-def reload_i3():%0A    %22%22%22Reload i3 colors.%22%22%22%0A    if shutil.which(%22i3-msg%22):%0A        util.disown(%22i3-msg%22, %22reload%22)%0A%0A%0A
 def 
@@ -308,16 +308,134 @@
 es%22%5D)%0A%0A%0A
+def reload_i3():%0A    %22%22%22Reload i3 colors.%22%22%22%0A    if shutil.which(%22i3-msg%22):%0A        util.disown(%22i3-msg%22, %22reload%22)%0A%0A%0A
 def relo
@@ -494,18 +494,20 @@
  reload_
-i3
+xrdb
 ()%0A    r
@@ -508,28 +508,26 @@
 %0A    reload_
-xrdb
+i3
 ()%0A    print

Fix bug with i3 titlebars not being the right color.