api: Added function to load colors from file.

This commit is contained in:
Dylan Araps 2017-07-23 14:51:42 +10:00
parent a0c130cbda
commit 38fcae33a0
3 changed files with 11 additions and 4 deletions

View File

@ -91,7 +91,7 @@ def process_args(args):
colors_plain = colors.get(image_file, notify=not args.q)
if args.f:
colors_plain = util.read_file_json(args.f)
colors_plain = colors.load(args.f)
if args.i or args.f:
sequences.send(colors_plain, args.t)

View File

@ -93,3 +93,13 @@ def get(img, cache_dir=__cache_dir__,
util.msg("wal: Generation complete.", notify)
return colors
def file(input_file):
"""Import colorscheme from json file."""
data = util.read_file_json(input_file)
if "wallpaper" not in data:
data["wallpaper"] = "None"
return data

View File

@ -55,9 +55,6 @@ def read_file_json(input_file):
with open(input_file, "r") as json_file:
data = json.load(json_file)
if "wallpaper" not in data:
data["wallpaper"] = "None"
return data