general: Make -R work with theme files.

This commit is contained in:
Dylan Araps 2018-04-01 15:50:08 +10:00
parent e8ebff1247
commit 3c7c8516e5

View File

@ -128,15 +128,6 @@ def process_args(args):
scheme_dir = os.path.join(CACHE_DIR, "schemes") scheme_dir = os.path.join(CACHE_DIR, "schemes")
shutil.rmtree(scheme_dir, ignore_errors=True) shutil.rmtree(scheme_dir, ignore_errors=True)
if args.R:
image_file = os.path.join(CACHE_DIR, "wal")
if os.path.isfile(image_file):
args.i = util.read_file(image_file)[0]
else:
print("image: No colorscheme to restore, try 'wal -i' first.")
sys.exit(1)
if args.i: if args.i:
image_file = image.get(args.i) image_file = image.get(args.i)
colors_plain = colors.get(image_file, args.l, args.backend) colors_plain = colors.get(image_file, args.l, args.backend)
@ -144,6 +135,16 @@ def process_args(args):
if args.theme: if args.theme:
colors_plain = theme.file(args.theme) colors_plain = theme.file(args.theme)
if args.R:
cache_file = os.path.join(CACHE_DIR, "colors.json")
if os.path.isfile(cache_file):
colors_plain = theme.file(cache_file)
else:
print("image: No colorscheme to restore, try 'wal -i' first.")
sys.exit(1)
if args.a: if args.a:
util.Color.alpha_num = args.a util.Color.alpha_num = args.a
@ -152,7 +153,7 @@ def process_args(args):
colors_plain["special"]["background"] = args.b colors_plain["special"]["background"] = args.b
colors_plain["colors"]["color0"] = args.b colors_plain["colors"]["color0"] = args.b
if args.i or args.theme: if args.i or args.theme or args.R:
if not args.n: if not args.n:
wallpaper.change(colors_plain["wallpaper"]) wallpaper.change(colors_plain["wallpaper"])