From dc8ca8af2792090c83ee58749b72e40e66301625 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 1 Apr 2018 16:40:17 +1000 Subject: [PATCH] general: Add palette to output. --- pywal/__main__.py | 1 + pywal/colors.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/pywal/__main__.py b/pywal/__main__.py index eb2c6e7..d273cc1 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -158,6 +158,7 @@ def process_args(args): wallpaper.change(colors_plain["wallpaper"]) sequences.send(colors_plain, to_send=not args.s) + colors.palette() export.every(colors_plain) if not args.e: diff --git a/pywal/colors.py b/pywal/colors.py index 280f090..157f7df 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -89,6 +89,24 @@ def get_backend(backend): random.shuffle(backends) return backends[0] + return backend + + +def palette(): + """Generate a palette from the colors.""" + col_width = " " * (os.get_terminal_size().columns // 8) + + 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, col_width), end="") + + print("\n") + def get(img, light=False, backend="wal", cache_dir=CACHE_DIR): """Generate a palette."""