File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1- __version__ = "2.0.6 "
1+ __version__ = "2.0.7 "
Original file line number Diff line number Diff line change 6666APPROX_CHROMA = 50
6767DEFAULT_RESIZE_BITMAP_AREA = 112 * 112
6868
69+ WALLPAPER_CACHE = {}
70+
6971
7072def _is_android () -> bool :
7173 try :
@@ -262,8 +264,25 @@ def get_dynamic_scheme(
262264 logger ("Failed to get system wallpaper : " + str (e ))
263265 fallback_wallpaper_path = None
264266
267+ if all (
268+ [
269+ not selected_color ,
270+ not selected_scheme ,
271+ fallback_wallpaper_path in WALLPAPER_CACHE .keys ()
272+ and WALLPAPER_CACHE [fallback_wallpaper_path ][1 ]
273+ == os .path .getsize (fallback_wallpaper_path ),
274+ ]
275+ ):
276+ logger (
277+ "Got wallpaper color from cache '{}'" .format (
278+ WALLPAPER_CACHE [fallback_wallpaper_path ][0 ]
279+ )
280+ )
281+ selected_color = WALLPAPER_CACHE [fallback_wallpaper_path ][0 ]
282+
265283 if (
266- not selected_color
284+ not selected_scheme
285+ and not selected_color
267286 and fallback_wallpaper_path
268287 and (image := open_wallpaper_file (fallback_wallpaper_path ))
269288 ):
@@ -282,6 +301,10 @@ def get_dynamic_scheme(
282301 timer_start = default_timer ()
283302 colors = QuantizeCelebi (pixel_array , 128 )
284303 selected_color = Score .score (colors )[0 ]
304+ WALLPAPER_CACHE [fallback_wallpaper_path ] = [
305+ selected_color ,
306+ os .path .getsize (fallback_wallpaper_path ),
307+ ]
285308 logger (f"Got dominant colors - " f"{ default_timer () - timer_start } sec." )
286309
287310 return (
You can’t perform that action at this time.
0 commit comments