mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-20 17:15:41 +02:00
wallpaper: give a chance to rare images to be selected
Duplicates are allowed.
This commit is contained in:
parent
bf7ed44e0b
commit
688c667b22
1 changed files with 7 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue