main: add -f flag to read colorscheme from file

This commit is contained in:
Paul Bienkowski 2017-06-28 14:35:28 +02:00
parent a249f2083b
commit 76ec7f6cdc

View File

@ -27,6 +27,9 @@ def get_args():
arg.add_argument("-i", metavar="\"/path/to/img.jpg\"", arg.add_argument("-i", metavar="\"/path/to/img.jpg\"",
help="Which image or directory to use.") help="Which image or directory to use.")
arg.add_argument("-f", metavar="\"/path/to/colorscheme/file\"",
help="Which colorscheme file to use.")
arg.add_argument("-n", action="store_true", arg.add_argument("-n", action="store_true",
help="Skip setting the wallpaper.") help="Skip setting the wallpaper.")
@ -58,6 +61,11 @@ def process_args(args):
" Refer to \"wal -h\" for more info.") " Refer to \"wal -h\" for more info.")
exit(1) exit(1)
if args.i and args.f:
print("error: conflicting arguments -i and -f.\n"
" Refer to \"wal -h\" for more info.")
exit(1)
# -q # -q
if args.q: if args.q:
sys.stdout = sys.stderr = open(os.devnull, "w") sys.stdout = sys.stderr = open(os.devnull, "w")
@ -91,6 +99,12 @@ def process_args(args):
set_colors.send_sequences(colors_plain, args.t) set_colors.send_sequences(colors_plain, args.t)
export_colors.export_colors(colors_plain) export_colors.export_colors(colors_plain)
# -f
elif args.f:
colors_plain = util.read_file(args.f)
set_colors.send_sequences(colors_plain, args.t)
export_colors.export_colors(colors_plain)
# -o # -o
if args.o: if args.o:
util.disown(args.o) util.disown(args.o)