Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def process_args(args):
if args.light:
settings["light_theme"] = "true"
if args.n:
settings["set_wallpaper"] = "false"
if args.alpha:
settings["alpha"] = args.alpha[0]
if args.backend and args.backend != "list":
if args.backend in pywal.colors.list_backends():
settings['backend'] = args.backend
else:
logging.error("no such backend, please "
"choose a valid backend")
exit(1)
if args.preview:
def write_script(wallpaper, colorscheme):
"""writes the script that should be called on startup
to restore the theme."""
set_wall = settings.getboolean("set_wallpaper", True)
light_theme = settings.getboolean("light_theme", True)
flags = "-rs" if set_wall else "-nrs"
flags += "L" if light_theme else ""
with open(join(WPG_DIR, "wp_init.sh"), "w") as script:
command = "wpg %s '%s' '%s'" % (flags, wallpaper, colorscheme)
script.writelines(["#!/usr/bin/env bash\n", command])
def load_opt_list(self):
current_backend = settings.get("backend", "wal")
i = self.backend_list.index(current_backend)
self.backend_combo.set_active(i)
self.color_combo\
.set_active(settings.getint("active", 0))
self.gtk_switch\
.set_active(settings.getboolean("gtk", True))
self.command_switch\
.set_active(settings.getboolean("execute_cmd", False))
self.light_theme_switch\
.set_active(settings.getboolean("light_theme", False))
self.wallpaper_switch\
.set_active(settings.getboolean("set_wallpaper", True))
self.smart_sort_switch\
.set_active(settings.getboolean("smart_sort", True))
self.auto_adjust_switch\
.set_active(settings.getboolean("auto_adjust", False))
self.editor_txt\
.set_text(settings.get("editor", "urxvt -e vim"))
self.command_txt\
.set_text(settings.get("command", "yes hi"))
self.command_txt\
.set_editable(settings.getboolean("execute_cmd", False))
self.alpha_txt\
def get_pywal_dict(wallpaper, is_file=False):
"""get the color dictionary of a given wallpaper"""
light_theme = settings.getboolean("light_theme", False)
pywal.util.Color.alpha_num = settings.get("alpha", "100")
image = pywal.image.get(os.path.join(WALL_DIR, wallpaper))
return pywal.colors.get(
image,
light=(is_file and light_theme),
backend=settings.get("backend", "wal"),
cache_dir=WPG_DIR
)
def get_sample_path(wallpaper, backend=None):
"""gets a wallpaper colorscheme sample's path"""
if not backend:
backend = settings.get("backend", "wal")
sample_filename = "%s_%s_sample.png" % (wallpaper, backend)
return join(SAMPLE_DIR, sample_filename)
.set_active(settings.getint("active", 0))
self.gtk_switch\
.set_active(settings.getboolean("gtk", True))
self.command_switch\
.set_active(settings.getboolean("execute_cmd", False))
self.light_theme_switch\
.set_active(settings.getboolean("light_theme", False))
self.wallpaper_switch\
.set_active(settings.getboolean("set_wallpaper", True))
self.smart_sort_switch\
.set_active(settings.getboolean("smart_sort", True))
self.auto_adjust_switch\
.set_active(settings.getboolean("auto_adjust", False))
self.editor_txt\
.set_text(settings.get("editor", "urxvt -e vim"))
self.command_txt\
.set_text(settings.get("command", "yes hi"))
self.command_txt\
.set_editable(settings.getboolean("execute_cmd", False))
self.alpha_txt\
.set_text(settings.get("alpha", "100"))
def load_opt_list(self):
current_backend = settings.get("backend", "wal")
i = self.backend_list.index(current_backend)
self.backend_combo.set_active(i)
self.color_combo\
.set_active(settings.getint("active", 0))
self.gtk_switch\
.set_active(settings.getboolean("gtk", True))
self.command_switch\
.set_active(settings.getboolean("execute_cmd", False))
self.light_theme_switch\
.set_active(settings.getboolean("light_theme", False))
self.wallpaper_switch\
.set_active(settings.getboolean("set_wallpaper", True))
self.smart_sort_switch\
.set_active(settings.getboolean("smart_sort", True))
self.auto_adjust_switch\
.set_active(settings.getboolean("auto_adjust", False))
self.editor_txt\
.set_text(settings.get("editor", "urxvt -e vim"))
self.command_txt\
def get_pywal_dict(wallpaper, is_file=False):
"""get the color dictionary of a given wallpaper"""
light_theme = settings.getboolean("light_theme", False)
pywal.util.Color.alpha_num = settings.get("alpha", "100")
image = pywal.image.get(os.path.join(WALL_DIR, wallpaper))
return pywal.colors.get(
image,
light=(is_file and light_theme),
backend=settings.get("backend", "wal"),
cache_dir=WPG_DIR
)
def on_activate(self, switch, *gparam):
if(gparam[1] == 'execute_cmd'):
self.command_txt.set_editable(switch.get_active())
settings[gparam[1]] = str(switch.get_active()).lower()
self.lbl_save.set_text('')
def get_color_dict(cdic):
"""ensamble wpgtk color dictionary"""
index = settings.getint("active")
index = index if index > 0 else randint(9, 14)
base_color = cdic["colors"]["color%s" % index]
color_list = list(cdic["colors"].values())
all_colors = {
"wallpaper": cdic["wallpaper"],
"alpha": cdic["alpha"],
**cdic["special"],
**cdic["colors"],
**add_icon_colors(cdic),
**keyword_colors(base_color, is_dark_theme(color_list))
}
try:
user_words = {k: v.format(**all_colors)