mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-21 01:25:42 +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 argparse
|
||||||
import tempfile
|
import tempfile
|
||||||
import itertools
|
import itertools
|
||||||
|
import functools
|
||||||
|
import operator
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import inspect
|
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]
|
weights = [100 / ((count - min(counts) + 1) ** 3) for count in counts]
|
||||||
images = [
|
images = [
|
||||||
PIL.Image.open(image)
|
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:
|
for image in images:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue