aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pywal/colors.py14
-rw-r--r--pywal/settings.py3
-rw-r--r--pywal/theme.py57
-rw-r--r--pywal/util.py136
4 files changed, 0 insertions, 210 deletions
diff --git a/pywal/colors.py b/pywal/colors.py
index 33f6b6b..ef38322 100644
--- a/pywal/colors.py
+++ b/pywal/colors.py
@@ -132,20 +132,6 @@ def get_backend(backend):
return backend
-def palette():
- """Generate a palette from the colors."""
- for i in range(0, 16):
- if i % 8 == 0:
- print()
-
- if i > 7:
- i = "8;5;%s" % i
-
- print("\033[4%sm%s\033[0m" % (i, " " * (80 // 20)), end="")
-
- print("\n")
-
-
def get(img, light=False, backend="wal", cache_dir=CACHE_DIR, sat=""):
"""Generate a palette."""
# home_dylan_img_jpg_backend_1.2.2.json
diff --git a/pywal/settings.py b/pywal/settings.py
index 68f8dae..c01c8a0 100644
--- a/pywal/settings.py
+++ b/pywal/settings.py
@@ -28,7 +28,6 @@ Created by Dylan Araps.
"""
import os
-import platform
__version__ = "3.3.1"
@@ -42,5 +41,3 @@ XDG_CONF_DIR = os.getenv("XDG_CONFIG_HOME", os.path.join(HOME, ".config"))
CACHE_DIR = os.getenv("PYWAL_CACHE_DIR", os.path.join(XDG_CACHE_DIR, "wal"))
CONF_DIR = os.path.join(XDG_CONF_DIR, "wal")
MODULE_DIR = os.path.dirname(__file__)
-
-OS = platform.uname()[0]
diff --git a/pywal/theme.py b/pywal/theme.py
index 94646cf..5abf242 100644
--- a/pywal/theme.py
+++ b/pywal/theme.py
@@ -29,54 +29,6 @@ from .settings import CACHE_DIR, CONF_DIR, MODULE_DIR
from . import util
-def list_out():
- """List all themes in a pretty format."""
- dark_themes = [theme.name.replace(".json", "") for theme in list_themes()]
- ligh_themes = [theme.name.replace(".json", "") for theme in list_themes(dark=False)]
- user_themes = [theme.name.replace(".json", "") for theme in list_themes_user()]
-
- try:
- last_used_theme = util.read_file(os.path.join(CACHE_DIR, "last_used_theme"))[
- 0
- ].replace(".json", "")
- except FileNotFoundError:
- last_used_theme = ""
-
- if user_themes:
- print("\033[1;32mUser Themes\033[0m:")
- print(
- " -",
- "\n - ".join(
- t + " (last used)" if t == last_used_theme else t
- for t in sorted(user_themes)
- ),
- )
-
- print("\033[1;32mDark Themes\033[0m:")
- print(
- " -",
- "\n - ".join(
- t + " (last used)" if t == last_used_theme else t
- for t in sorted(dark_themes)
- ),
- )
-
- print("\033[1;32mLight Themes\033[0m:")
- print(
- " -",
- "\n - ".join(
- t + " (last used)" if t == last_used_theme else t
- for t in sorted(ligh_themes)
- ),
- )
-
- print("\033[1;32mExtra\033[0m:")
- print(" - random (select a random dark theme)")
- print(" - random_dark (select a random dark theme)")
- print(" - random_light (select a random light theme)")
- print(" - random_user (select a random user theme)")
-
-
def list_themes(dark=True):
"""List all installed theme files."""
dark = "dark" if dark else "light"
@@ -178,12 +130,3 @@ def file(input_file, light=False):
logging.error("Try adding '-l' to set light themes.")
logging.error("Try removing '-l' to set dark themes.")
sys.exit(1)
-
-
-def save(colors, theme_name, light=False):
- """Save colors to a theme file."""
- theme_file = theme_name + ".json"
- theme_path = os.path.join(
- CONF_DIR, "colorschemes", "light" if light else "dark", theme_file
- )
- util.save_file_json(colors, theme_path)
diff --git a/pywal/util.py b/pywal/util.py
index 5be5f5c..bdb0e94 100644
--- a/pywal/util.py
+++ b/pywal/util.py
@@ -23,11 +23,6 @@ import colorsys
import json
import logging
import os
-import platform
-import re
-import shutil
-import subprocess
-import sys
class Color:
@@ -42,91 +37,10 @@ class Color:
return self.hex_color
@property
- def rgb(self):
- """Convert a hex color to rgb."""
- return "%s,%s,%s" % (*hex_to_rgb(self.hex_color),)
-
- @property
- def xrgba(self):
- """Convert a hex color to xrdb rgba."""
- return hex_to_xrgba(self.hex_color)
-
- @property
- def rgba(self):
- """Convert a hex color to rgba."""
- return "rgba(%s,%s,%s,%s)" % (*hex_to_rgb(self.hex_color), self.alpha_dec)
-
- @property
- def alpha(self):
- """Add URxvt alpha value to color."""
- return "[%s]%s" % (self.alpha_num, self.hex_color)
-
- @property
- def alpha_dec(self):
- """Export the alpha value as a decimal number in [0, 1]."""
- return int(self.alpha_num) / 100
-
- @property
- def decimal(self):
- """Export color in decimal."""
- return "%s%s" % ("#", int(self.hex_color[1:], 16))
-
- @property
- def decimal_strip(self):
- """Strip '#' from decimal color."""
- return int(self.hex_color[1:], 16)
-
- @property
- def octal(self):
- """Export color in octal."""
- return "%s%s" % ("#", oct(int(self.hex_color[1:], 16))[2:])
-
- @property
- def octal_strip(self):
- """Strip '#' from octal color."""
- return oct(int(self.hex_color[1:], 16))[2:]
-
- @property
def strip(self):
"""Strip '#' from color."""
return self.hex_color[1:]
- @property
- def red(self):
- """Red value as float between 0 and 1."""
- return "%.3f" % (hex_to_rgb(self.hex_color)[0] / 255.0)
-
- @property
- def green(self):
- """Green value as float between 0 and 1."""
- return "%.3f" % (hex_to_rgb(self.hex_color)[1] / 255.0)
-
- @property
- def blue(self):
- """Blue value as float between 0 and 1."""
- return "%.3f" % (hex_to_rgb(self.hex_color)[2] / 255.0)
-
- def lighten(self, percent):
- """Lighten color by percent."""
- percent = float(re.sub(r"[\D\.]", "", str(percent)))
- return Color(lighten_color(self.hex_color, percent / 100))
-
- def darken(self, percent):
- """Darken color by percent."""
- percent = float(re.sub(r"[\D\.]", "", str(percent)))
- return Color(darken_color(self.hex_color, percent / 100))
-
- def saturate(self, percent):
- """Saturate a color."""
- percent = float(re.sub(r"[\D\.]", "", str(percent)))
- return Color(saturate_color(self.hex_color, percent / 100))
-
-
-def read_file(input_file):
- """Read data from a file and trim newlines."""
- with open(input_file, "r") as file:
- return file.read().splitlines()
-
def read_file_json(input_file):
"""Read data from a json file."""
@@ -134,13 +48,6 @@ def read_file_json(input_file):
return json.load(json_file)
-def read_file_raw(input_file):
- """Read data from a file as is, don't strip
- newlines or other special characters."""
- with open(input_file, "r") as file:
- return file.readlines()
-
-
def save_file(data, export_file):
"""Write data to a file."""
create_dir(os.path.dirname(export_file))
@@ -165,31 +72,11 @@ def create_dir(directory):
os.makedirs(directory, exist_ok=True)
-def setup_logging():
- """Logging config."""
- logging.basicConfig(
- format=(
- "[%(levelname)s\033[0m] " "\033[1;31m%(module)s\033[0m: " "%(message)s"
- ),
- level=logging.INFO,
- stream=sys.stdout,
- )
- logging.addLevelName(logging.ERROR, "\033[1;31mE")
- logging.addLevelName(logging.INFO, "\033[1;32mI")
- logging.addLevelName(logging.WARNING, "\033[1;33mW")
-
-
def hex_to_rgb(color):
"""Convert a hex color to rgb."""
return tuple(bytes.fromhex(color.strip("#")))
-def hex_to_xrgba(color):
- """Convert a hex color to xrdb rgba."""
- col = color.lower().strip("#")
- return "%s%s/%s%s/%s%s/ff" % (*col,)
-
-
def rgb_to_hex(color):
"""Convert an rgb color to hex."""
return "#%02x%02x%02x" % (*color,)
@@ -234,26 +121,3 @@ def saturate_color(color, amount):
def rgb_to_yiq(color):
"""Sort a list of colors."""
return colorsys.rgb_to_yiq(*hex_to_rgb(color))
-
-
-def disown(cmd):
- """Call a system command in the background,
- disown it and hide it's output."""
- subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
-
-
-def get_pid(name):
- """Check if process is running by name."""
- if not shutil.which("pidof"):
- return False
-
- try:
- if platform.system() != "Darwin":
- subprocess.check_output(["pidof", "-s", name])
- else:
- subprocess.check_output(["pidof", name])
-
- except subprocess.CalledProcessError:
- return False
-
- return True