diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2018-04-01 11:27:57 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2018-04-01 11:27:57 +1000 |
| commit | d5f39135b2d054af23c0af8594ee772b2a544669 (patch) | |
| tree | c34f1583c417079227138874476596ac7c16ae12 /pywal | |
| parent | d8dd569dc14d01885053898151a76c70ab33589b (diff) | |
backend: Add random option
Diffstat (limited to 'pywal')
| -rw-r--r-- | pywal/__main__.py | 5 | ||||
| -rw-r--r-- | pywal/colors.py | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/pywal/__main__.py b/pywal/__main__.py index 09d0769..c1c4002 100644 --- a/pywal/__main__.py +++ b/pywal/__main__.py @@ -38,12 +38,13 @@ def get_args(args): help="Custom background color to use.") arg.add_argument("--backend", metavar="backend", - help="Which color backend to use.", + help="Which color backend to use. \ + Use 'wal --backend' to list backends.", const="list_backends", type=str, nargs="?", default="wal") arg.add_argument("--theme", metavar="/path/to/file or theme_name", help="Which colorscheme file to use. \ - Use 'wal -f' to list available builtin themes.", + Use 'wal --theme' to list builtin themes.", const="list_themes", nargs="?") arg.add_argument("-c", action="store_true", diff --git a/pywal/colors.py b/pywal/colors.py index 33b68d5..5472ef5 100644 --- a/pywal/colors.py +++ b/pywal/colors.py @@ -2,6 +2,7 @@ Generate a palette using various backends. """ import os +import random import re import sys @@ -94,6 +95,13 @@ def get(img, light=False, backend="wal", cache_dir=CACHE_DIR): else: print("wal: Generating a colorscheme...") + if backend == "random": + backends = list_backends() + random.shuffle(backends) + backend = backends[0] + + print("wal: Using", backend, "backend.") + # Dynamically import the backend we want to use. # This keeps the dependencies "optional". try: |
