diff --git a/bin/wallpaper b/bin/wallpaper index 437beca..714e62c 100755 --- a/bin/wallpaper +++ b/bin/wallpaper @@ -22,6 +22,8 @@ import random import argparse import tempfile import itertools +import functools +import operator import logging import logging.handlers import inspect @@ -223,7 +225,11 @@ def get_random_images(directory: str, number: int) -> list[Image]: weights = [100 / ((count - min(counts) + 1) ** 3) for count in counts] images = [ PIL.Image.open(image) - for image in random.choices(image_files, k=number, weights=weights) + for image in functools.reduce( + operator.add, + (random.choices(image_files, weights=weights) for k in range(number)), + [], + ) ] for image in images: