mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-06-19 17:19:08 +02:00
commit
d168d961a5
@ -14,7 +14,7 @@ import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
from .settings import __version__, __cache_dir__
|
||||
from .settings import __version__, CACHE_DIR
|
||||
from . import colors
|
||||
from . import export
|
||||
from . import image
|
||||
@ -85,7 +85,7 @@ def process_args(args):
|
||||
sys.stdout = sys.stderr = open(os.devnull, "w")
|
||||
|
||||
if args.c:
|
||||
shutil.rmtree(__cache_dir__ / "schemes", ignore_errors=True)
|
||||
shutil.rmtree(CACHE_DIR / "schemes", ignore_errors=True)
|
||||
|
||||
if args.r:
|
||||
reload.colors(args.t)
|
||||
|
@ -5,7 +5,7 @@ import re
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from .settings import __cache_dir__, __color_count__
|
||||
from .settings import CACHE_DIR, COLOR_COUNT
|
||||
from . import util
|
||||
|
||||
|
||||
@ -72,8 +72,8 @@ def sort_colors(img, colors):
|
||||
return colors
|
||||
|
||||
|
||||
def get(img, cache_dir=__cache_dir__,
|
||||
color_count=__color_count__, notify=False):
|
||||
def get(img, cache_dir=CACHE_DIR,
|
||||
color_count=COLOR_COUNT, notify=False):
|
||||
"""Get the colorscheme."""
|
||||
# _home_dylan_img_jpg.json
|
||||
cache_file = cache_dir / "schemes" / \
|
||||
|
@ -4,13 +4,10 @@ Export colors in various formats.
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
from .settings import __cache_dir__
|
||||
from .settings import CACHE_DIR, MODULE_DIR
|
||||
from . import util
|
||||
|
||||
|
||||
TEMPLATE_DIR = pathlib.Path(__file__).parent / "templates"
|
||||
|
||||
|
||||
def template(colors, input_file, output_file=None):
|
||||
"""Read template file, substitute markers and
|
||||
save the file elsewhere."""
|
||||
@ -42,12 +39,12 @@ def get_export_type(export_type):
|
||||
}.get(export_type, export_type)
|
||||
|
||||
|
||||
def every(colors, output_dir=__cache_dir__):
|
||||
def every(colors, output_dir=CACHE_DIR):
|
||||
"""Export all template files."""
|
||||
all_colors = flatten_colors(colors)
|
||||
output_dir = pathlib.Path(output_dir)
|
||||
|
||||
for file in os.scandir(TEMPLATE_DIR):
|
||||
for file in os.scandir(MODULE_DIR / "templates"):
|
||||
template(all_colors, file.path, output_dir / file.name)
|
||||
|
||||
print(f"export: Exported all files.")
|
||||
@ -58,8 +55,8 @@ def color(colors, export_type, output_file=None):
|
||||
all_colors = flatten_colors(colors)
|
||||
|
||||
template_name = get_export_type(export_type)
|
||||
template_file = TEMPLATE_DIR / template_name
|
||||
output_file = output_file or __cache_dir__ / template_name
|
||||
template_file = MODULE_DIR / "templates" / template_name
|
||||
output_file = output_file or CACHE_DIR / template_name
|
||||
|
||||
if template_file.is_file():
|
||||
template(all_colors, template_file, output_file)
|
||||
|
@ -5,7 +5,7 @@ import os
|
||||
import pathlib
|
||||
import random
|
||||
|
||||
from .settings import __cache_dir__
|
||||
from .settings import CACHE_DIR
|
||||
from . import util
|
||||
from . import wallpaper
|
||||
|
||||
@ -26,7 +26,7 @@ def get_random_image(img_dir):
|
||||
return str(img_dir / random.choice(images).name)
|
||||
|
||||
|
||||
def get(img, cache_dir=__cache_dir__):
|
||||
def get(img, cache_dir=CACHE_DIR):
|
||||
"""Validate image input."""
|
||||
image = pathlib.Path(img)
|
||||
|
||||
|
@ -1,18 +1,17 @@
|
||||
"""
|
||||
Reload programs.
|
||||
"""
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from .settings import __cache_dir__
|
||||
from .settings import CACHE_DIR, HOME, MODULE_DIR
|
||||
from . import util
|
||||
|
||||
|
||||
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"
|
||||
xrdb_file = xrdb_file or CACHE_DIR / "colors.Xresources"
|
||||
|
||||
if shutil.which("xrdb"):
|
||||
subprocess.call(["xrdb", "-merge", xrdb_file],
|
||||
@ -22,9 +21,8 @@ def xrdb(xrdb_file=None):
|
||||
|
||||
def gtk():
|
||||
"""Move gtkrc files to the correct location."""
|
||||
home = pathlib.Path.home()
|
||||
theme_path = home / ".themes" / "Flatabulous-wal"
|
||||
gtk2_file = __cache_dir__ / "colors-gtk2.rc"
|
||||
theme_path = HOME / ".themes" / "Flatabulous-wal"
|
||||
gtk2_file = CACHE_DIR / "colors-gtk2.rc"
|
||||
|
||||
if theme_path.is_dir():
|
||||
if gtk2_file.is_file():
|
||||
@ -34,8 +32,7 @@ def gtk():
|
||||
# This is done because the Python 3 GTK/Gdk libraries don't
|
||||
# provide a way of doing this.
|
||||
if shutil.which("python2"):
|
||||
module_dir = pathlib.Path(__file__).parent
|
||||
util.disown("python2", module_dir / "scripts" / "gtk_reload.py")
|
||||
util.disown("python2", MODULE_DIR / "scripts" / "gtk_reload.py")
|
||||
|
||||
|
||||
def i3():
|
||||
@ -52,14 +49,14 @@ def polybar():
|
||||
|
||||
def env(xrdb_file=None):
|
||||
"""Reload environment."""
|
||||
xrdb(xrdb_file)
|
||||
gtk()
|
||||
xrdb(xrdb_file)
|
||||
i3()
|
||||
polybar()
|
||||
print("reload: Reloaded environment.")
|
||||
|
||||
|
||||
def colors(vte, cache_dir=__cache_dir__):
|
||||
def colors(vte, cache_dir=CACHE_DIR):
|
||||
"""Reload the current scheme."""
|
||||
sequence_file = cache_dir / "sequences"
|
||||
|
||||
|
@ -3,7 +3,7 @@ Send sequences to all open terminals.
|
||||
"""
|
||||
import os
|
||||
|
||||
from .settings import __cache_dir__
|
||||
from .settings import CACHE_DIR
|
||||
from . import util
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ def set_color(index, color):
|
||||
return f"\033]4;{index};{color}\007"
|
||||
|
||||
|
||||
def send(colors, vte, cache_dir=__cache_dir__):
|
||||
def send(colors, vte, cache_dir=CACHE_DIR):
|
||||
"""Send colors to all open terminals."""
|
||||
# Colors 0-15.
|
||||
sequences = [set_color(num, color)
|
||||
|
@ -11,6 +11,11 @@ Created by Dylan Araps.
|
||||
|
||||
import pathlib
|
||||
|
||||
|
||||
__version__ = "0.5.0"
|
||||
__cache_dir__ = pathlib.Path.home() / ".cache/wal/"
|
||||
__color_count__ = 16
|
||||
|
||||
|
||||
HOME = pathlib.Path.home()
|
||||
CACHE_DIR = HOME / ".cache/wal/"
|
||||
MODULE_DIR = pathlib.Path(__file__).parent
|
||||
COLOR_COUNT = 16
|
||||
|
@ -3,7 +3,7 @@ import os
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from .settings import __cache_dir__
|
||||
from .settings import CACHE_DIR
|
||||
from . import util
|
||||
|
||||
|
||||
@ -97,7 +97,7 @@ def change(img):
|
||||
print("wallpaper: Set the new wallpaper")
|
||||
|
||||
|
||||
def get(cache_dir=__cache_dir__):
|
||||
def get(cache_dir=CACHE_DIR):
|
||||
"""Get the current wallpaper."""
|
||||
current_wall = cache_dir / "wal"
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
import unittest
|
||||
|
||||
from pywal import __main__
|
||||
from pywal.settings import __cache_dir__
|
||||
from pywal.settings import CACHE_DIR
|
||||
|
||||
|
||||
class TestMain(unittest.TestCase):
|
||||
@ -12,7 +12,7 @@ class TestMain(unittest.TestCase):
|
||||
"""> Test arg parsing (-c)"""
|
||||
args = __main__.get_args(["-c"])
|
||||
__main__.process_args(args)
|
||||
self.assertFalse((__cache_dir__ / "schemes").is_dir())
|
||||
self.assertFalse((CACHE_DIR / "schemes").is_dir())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user