def get_colors(img, quiet): """Generate a colorscheme using imagemagick.""" # Cache the wallpaper name. util.save_file(img, CACHE_DIR / "wal") # Cache the sequences file. cache_file = pathlib.Path(CACHE_DIR / "schemes" / img.replace("/", "_")) if cache_file.is_file(): colors = util.read_file(cache_file) print("colors: Found cached colorscheme.") else: print("colors: Generating a colorscheme...") if not quiet: util.disown("notify-send", "wal: Generating a colorscheme...") # Generate the colors. colors = gen_colors(img) colors = sort_colors(colors) # Cache the colorscheme. util.save_file("\n".join(colors), cache_file) print("colors: Generated colorscheme") if not quiet: util.disown("notify-send", "wal: Generation complete.") return colors
def get_colors(img, quiet): """Get the colorscheme.""" # Cache the wallpaper name. util.save_file(img, CACHE_DIR / "wal") # Cache the sequences file. # _home_dylan_img_jpg.json cache_file = CACHE_DIR / "schemes" / \ img.replace("/", "_").replace(".", "_") cache_file = cache_file.with_suffix(".json") if cache_file.is_file(): colors = util.read_file_json(cache_file) print("colors: Found cached colorscheme.") else: print("colors: Generating a colorscheme...") if not quiet: util.disown("notify-send", "wal: Generating a colorscheme...") # Generate the colors. colors = gen_colors(img) colors = sort_colors(img, colors) # Cache the colorscheme. util.save_file_json(colors, cache_file) print("colors: Generated colorscheme") if not quiet: util.disown("notify-send", "wal: Generation complete.") return colors
def process_args(args): """Process args.""" # If no args were passed. if not len(sys.argv) > 1: print("error: wal needs to be given arguments to run.\n" " Refer to \"wal -h\" for more info.") 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 if args.q: sys.stdout = sys.stderr = open(os.devnull, "w") # -c if args.c: shutil.rmtree(CACHE_DIR / "schemes") util.create_dir(CACHE_DIR / "schemes") # -r if args.r: sequences.reload_colors(args.t) # -v if args.v: print(f"wal {__version__}") exit(0) # -i if args.i: image_file = image.get_image(args.i) # Create a list of hex colors. colors_plain = magic.get_colors(image_file, args.q) if not args.n: wallpaper.set_wallpaper(image_file) # -f elif args.f: colors_plain = util.read_file_json(args.f) # -i or -f if args.i or args.f: sequences.send_sequences(colors_plain, args.t) export.export_all_templates(colors_plain) reload.reload_env() # -o if args.o: util.disown(args.o)
def process_args(args): """Process args.""" # If no args were passed. if not len(sys.argv) > 1: print("error: wal needs to be given arguments to run.\n" " Refer to \"wal -h\" for more info.") exit(1) # -q if args.q: sys.stdout = sys.stderr = open(os.devnull, "w") # -c if args.c: shutil.rmtree(CACHE_DIR / "schemes") util.create_dir(CACHE_DIR / "schemes") # -r if args.r: set_colors.reload_colors(args.t) # -v if args.v: print(f"wal {__version__}") exit(0) # -i if args.i: image = gen_colors.get_image(args.i) # Create a list of hex colors. colors_plain = gen_colors.get_colors(image, args.q) colors_plain[8] = set_colors.set_grey(colors_plain) if not args.n: wallpaper.set_wallpaper(image) # Set the colors. set_colors.send_sequences(colors_plain, args.t) export_colors.export_colors(colors_plain) # -o if args.o: util.disown(args.o)
def xfconf(path, img): """Call xfconf to set the wallpaper on XFCE.""" util.disown("xfconf-query", "--channel", "xfce4-desktop", "--property", path, "--set", img)
def reload_i3(): """Reload i3 colors.""" if shutil.which("i3-msg"): util.disown("i3-msg", "reload")