summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2017-06-26 23:36:36 +1000
committerDylan Araps <dylan.araps@gmail.com>2017-06-26 23:36:36 +1000
commit7a723eb173509349e2ebe5b3e706a9cb1fd4be76 (patch)
tree2feab64b8d2d180838086230e71c827d8feaa607
parent0b38d7affc52f002d29f551f96d9d225928d095d (diff)
General: Rename globals to settings and import constants we need.
-rwxr-xr-xpywal/__init__.py5
-rwxr-xr-xpywal/__main__.py10
-rwxr-xr-xpywal/export_colors.py6
-rwxr-xr-xpywal/gen_colors.py18
-rwxr-xr-xpywal/set_colors.py6
-rwxr-xr-xpywal/settings.py (renamed from pywal/globals.py)0
6 files changed, 21 insertions, 24 deletions
diff --git a/pywal/__init__.py b/pywal/__init__.py
index 480a0b4..006f780 100755
--- a/pywal/__init__.py
+++ b/pywal/__init__.py
@@ -2,7 +2,4 @@
wal - Generate and change colorschemes on the fly.
Created by Dylan Araps.
"""
-from pywal import globals as g
-
-
-__version__ = g.__version__
+from pywal.settings import __version__ # noqa: F401
diff --git a/pywal/__main__.py b/pywal/__main__.py
index 61c3771..e31fb5d 100755
--- a/pywal/__main__.py
+++ b/pywal/__main__.py
@@ -7,7 +7,7 @@ import os
import shutil
import sys
-from pywal import globals as g
+from pywal.settings import CACHE_DIR, __version__
from pywal import export_colors
from pywal import gen_colors
from pywal import set_colors
@@ -64,8 +64,8 @@ def process_args(args):
# -c
if args.c:
- shutil.rmtree(g.CACHE_DIR / "schemes")
- util.create_dir(g.CACHE_DIR / "schemes")
+ shutil.rmtree(CACHE_DIR / "schemes")
+ util.create_dir(CACHE_DIR / "schemes")
# -r
if args.r:
@@ -73,7 +73,7 @@ def process_args(args):
# -v
if args.v:
- print(f"wal {g.__version__}")
+ print(f"wal {__version__}")
exit(0)
# -i
@@ -98,7 +98,7 @@ def process_args(args):
def main():
"""Main script function."""
- util.create_dir(g.CACHE_DIR / "schemes")
+ util.create_dir(CACHE_DIR / "schemes")
args = get_args()
process_args(args)
diff --git a/pywal/export_colors.py b/pywal/export_colors.py
index faf5e93..93028aa 100755
--- a/pywal/export_colors.py
+++ b/pywal/export_colors.py
@@ -4,7 +4,7 @@ Export colors in various formats.
import shutil
import subprocess
-from pywal import globals as g
+from pywal.settings import CACHE_DIR
from pywal import util
from pywal import format_color
@@ -12,14 +12,14 @@ from pywal import format_color
def save_colors(colors, export_file, message):
"""Export colors to var format."""
colors = "".join(colors)
- util.save_file(colors, g.CACHE_DIR / export_file)
+ util.save_file(colors, CACHE_DIR / export_file)
print(f"export: exported {message}.")
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", g.CACHE_DIR / export_file])
+ subprocess.call(["xrdb", "-merge", CACHE_DIR / export_file])
def reload_i3():
diff --git a/pywal/gen_colors.py b/pywal/gen_colors.py
index 5c5fb1b..61e4cca 100755
--- a/pywal/gen_colors.py
+++ b/pywal/gen_colors.py
@@ -8,13 +8,13 @@ import re
import shutil
import subprocess
-from pywal import globals as g
+from pywal.settings import CACHE_DIR, COLOR_COUNT
from pywal import util
def random_img(img_dir):
"""Pick a random image file from a directory."""
- current_wall = pathlib.Path(g.CACHE_DIR / "wal")
+ current_wall = pathlib.Path(CACHE_DIR / "wal")
if current_wall.is_file():
current_wall = util.read_file(current_wall)
@@ -64,18 +64,18 @@ def gen_colors(img):
exit(1)
# Generate initial scheme.
- raw_colors = imagemagick(g.COLOR_COUNT, img)
+ raw_colors = imagemagick(COLOR_COUNT, img)
# If imagemagick finds less than 16 colors, use a larger source number
# of colors.
index = 0
- while len(raw_colors) - 1 < g.COLOR_COUNT:
+ while len(raw_colors) - 1 < COLOR_COUNT:
index += 1
- raw_colors = imagemagick(g.COLOR_COUNT + index, img)
+ raw_colors = imagemagick(COLOR_COUNT + index, img)
- print("colors: Imagemagick couldn't generate a", g.COLOR_COUNT,
+ print("colors: Imagemagick couldn't generate a", COLOR_COUNT,
"color palette, trying a larger palette size",
- g.COLOR_COUNT + index)
+ COLOR_COUNT + index)
# Remove the first element, which isn't a color.
del raw_colors[0]
@@ -87,10 +87,10 @@ def gen_colors(img):
def get_colors(img, quiet):
"""Generate a colorscheme using imagemagick."""
# Cache the wallpaper name.
- util.save_file(img, g.CACHE_DIR / "wal")
+ util.save_file(img, CACHE_DIR / "wal")
# Cache the sequences file.
- cache_file = pathlib.Path(g.CACHE_DIR / "schemes" / img.replace("/", "_"))
+ cache_file = pathlib.Path(CACHE_DIR / "schemes" / img.replace("/", "_"))
if cache_file.is_file():
colors = util.read_file(cache_file)
diff --git a/pywal/set_colors.py b/pywal/set_colors.py
index b8094bf..810e2d8 100755
--- a/pywal/set_colors.py
+++ b/pywal/set_colors.py
@@ -5,7 +5,7 @@ import os
import pathlib
import re
-from pywal import globals as g
+from pywal.settings import CACHE_DIR
from pywal import util
@@ -54,7 +54,7 @@ def send_sequences(colors, vte):
# Get a list of terminals.
terminals = [f"/dev/pts/{term}" for term in os.listdir("/dev/pts/")
if len(term) < 4]
- terminals.append(g.CACHE_DIR / "sequences")
+ terminals.append(CACHE_DIR / "sequences")
# Send the sequences to all open terminals.
# pylint: disable=W0106
@@ -65,7 +65,7 @@ def send_sequences(colors, vte):
def reload_colors(vte):
"""Reload colors."""
- sequence_file = pathlib.Path(g.CACHE_DIR / "sequences")
+ sequence_file = pathlib.Path(CACHE_DIR / "sequences")
if sequence_file.is_file():
sequences = "".join(util.read_file(sequence_file))
diff --git a/pywal/globals.py b/pywal/settings.py
index c72b37a..c72b37a 100755
--- a/pywal/globals.py
+++ b/pywal/settings.py