mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-26 07:49:17 +01:00
theme: Added random option. -f random
This commit is contained in:
parent
1cff79bcc6
commit
7c3e1ad4e8
@ -106,7 +106,9 @@ def process_args(args):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if args.f == "list_themes":
|
if args.f == "list_themes":
|
||||||
print("Themes:", ", ".join(theme.index()))
|
themes = theme.index()
|
||||||
|
themes = [theme.name.replace(".json", "") for theme in themes]
|
||||||
|
print("Themes:", ", ".join(themes))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if args.q:
|
if args.q:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
Theme file handling.
|
Theme file handling.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from .settings import CONF_DIR, MODULE_DIR
|
from .settings import CONF_DIR, MODULE_DIR
|
||||||
@ -10,9 +11,11 @@ from . import util
|
|||||||
|
|
||||||
def index():
|
def index():
|
||||||
"""List all installed theme files."""
|
"""List all installed theme files."""
|
||||||
themes = os.listdir(os.path.join(CONF_DIR, "colorschemes"))
|
themes = [theme for theme in
|
||||||
themes += os.listdir(os.path.join(MODULE_DIR, "colorschemes"))
|
os.scandir(os.path.join(CONF_DIR, "colorschemes"))]
|
||||||
return [theme.replace(".json", "") for theme in themes]
|
themes += [theme for theme in
|
||||||
|
os.scandir(os.path.join(MODULE_DIR, "colorschemes"))]
|
||||||
|
return themes
|
||||||
|
|
||||||
|
|
||||||
def terminal_sexy_to_wal(data):
|
def terminal_sexy_to_wal(data):
|
||||||
@ -46,6 +49,11 @@ def file(input_file):
|
|||||||
elif os.path.isfile(theme_file):
|
elif os.path.isfile(theme_file):
|
||||||
theme_file = theme_file
|
theme_file = theme_file
|
||||||
|
|
||||||
|
elif input_file == "random":
|
||||||
|
themes = [theme.path for theme in index()]
|
||||||
|
random.shuffle(themes)
|
||||||
|
theme_file = themes[0]
|
||||||
|
|
||||||
# Parse the theme file.
|
# Parse the theme file.
|
||||||
if os.path.isfile(theme_file):
|
if os.path.isfile(theme_file):
|
||||||
data = util.read_file_json(theme_file)
|
data = util.read_file_json(theme_file)
|
||||||
|
Loading…
Reference in New Issue
Block a user