Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
except IOError:
logging.error("file not found")
exit(1)
exit(0)
if args.theme == "list":
dark = settings['light_theme'] != "true"
name_dic = pywal.theme.list_themes(dark)
name_list = [t.name.replace(".json", "") for t in name_dic]
print("\n".join(name_list))
exit(0)
if args.sat:
cl = color.get_color_list(args.sat[0])
val = float(args.sat[1])
cl = [util.alter_brightness(x, 0, val) for x in cl]
color.write_colors(args.sat[0], cl)
sample.create_sample(cl, files.get_sample_path(args.sat[0]))
exit(0)
if args.brt:
cl = color.get_color_list(args.brt[0])
val = float(args.brt[1])
cl = [util.alter_brightness(x, val, 0) for x in cl]
color.write_colors(args.brt[0], cl)
sample.create_sample(cl, files.get_sample_path(args.brt[0]))
exit(0)
if args.theme and args.theme != "list":
light = settings['light_theme'] == "true"
def main():
util.setup_log()
args = read_args(sys.argv[1:])
process_arg_errors(args)
process_args(args)
try:
_gui = __import__("wpgtk.gui.theme_picker", fromlist=['theme_picker'])
_gui.run(args)
exit(0)
except NameError:
logging.error("missing pygobject module, use cli")
exit(1)
def render_buttons(self):
for x, button in enumerate(self.button_list):
gcolor = Gdk.color_parse(self.color_list[x])
if util.get_hls_val(self.color_list[x], 'light') < 99:
fgcolor = Gdk.color_parse('#FFFFFF')
else:
fgcolor = Gdk.color_parse('#000000')
button.set_label(self.color_list[x])
button.set_sensitive(True)
button.modify_bg(Gtk.StateType.NORMAL, gcolor)
button.modify_fg(Gtk.StateType.NORMAL, fgcolor)
def is_dark_theme(color_list):
"""compare brightness values to see if a color-scheme
is light or dark"""
fg_brightness = util.get_hls_val(color_list[7], "light")
bg_brightness = util.get_hls_val(color_list[0], "light")
return fg_brightness > bg_brightness
Gtk.STOCK_OK, Gtk.ResponseType.OK))
self.set_default_size(150, 100)
box = self.get_content_area()
box.set_border_width(10)
box.set_spacing(10)
sat_box = Gtk.Box(spacing=10, orientation=Gtk.Orientation.HORIZONTAL)
light_box = Gtk.Box(spacing=10, orientation=Gtk.Orientation.HORIZONTAL)
self.colorchooser = Gtk.ColorChooserWidget(show_editor=True)
self.colorchooser.set_use_alpha(False)
self.colorchooser.set_rgba(gcolor)
r, g, b, _ = list(map(lambda x: round(x*100*2.55), gcolor))
hue, light, sat = util.rgb_to_hls(r, g, b)
self.sat_lbl = Gtk.Label('Saturation')
self.light_lbl = Gtk.Label('Light ')
sat_range = Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0)
self.sat_slider = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL,
adjustment=sat_range)
self.sat_slider.set_value(-sat)
self.sat_slider.set_digits(2)
self.sat_slider.connect('value-changed', self.slider_changed, 'sat')
light_range = Gtk.Adjustment(5, 0, 255, 1, 10, 0)
self.light_slider = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL,
adjustment=light_range)
self.light_slider.set_value(light)
self.light_slider.connect('value-changed',
def is_dark_theme(color_list):
"""compare brightness values to see if a color-scheme
is light or dark"""
fg_brightness = util.get_hls_val(color_list[7], "light")
bg_brightness = util.get_hls_val(color_list[0], "light")
return fg_brightness > bg_brightness
# no settings daemon is running.
# So GTK is getting theme info from gtkrc file
# using xsettingd to set the same theme (parsing it from gtkrc)
elif shutil.which("xsettingsd") and os.path.isfile(settings_ini):
gtkrc = configparser.ConfigParser()
gtkrc.read(settings_ini)
if gtkrc["Settings"]:
theme = gtkrc["Settings"].get("gtk-theme-name", "FlatColor")
fd, path = tempfile.mkstemp()
try:
with os.fdopen(fd, "w+") as tmp:
tmp.write('Net/ThemeName "' + theme + '"\n')
tmp.close()
util.silent_call([
"timeout", "0.2s", "xsettingsd", "-c", path
])
logging.info(
"reloaded %s from settings.ini using xsettingsd"
% theme
)
finally:
os.remove(path)
# The system has no known settings daemon installed,
# but dconf gtk-theme exists, just refreshing its theme
# Because user might be using unknown settings daemon
elif shutil.which("gsettings") and gsettings_theme:
subprocess.Popen(refresh_gsettings.format(gsettings_theme), shell=True)
logging.warning(
"No settings daemon found, just refreshing %s theme from gsettings"
def keyword_colors(hexc, is_dark_theme=True):
"""extract active and inactive colors from a given
hex color value"""
brightness = util.get_hls_val(hexc, "light")
active = util.alter_brightness(hexc, brightness * -0.20) \
if is_dark_theme else util.alter_brightness(hexc, brightness * 0.30)
inactive = util.alter_brightness(hexc, brightness * -0.45) \
if is_dark_theme else hexc
return {
"active": active,
"inactive": inactive,
"newfront": active,
"newback": inactive,
"newglyph": util.alter_brightness(inactive, -15)
}