fix(wallpaper_changer): wallpaper bulder use correct dir, return image list
This commit is contained in:
1 parent
f0fd4a13e4
commit
7609177e35
1 file changed
+7
-5
@@ -19,13 +19,13 @@ class WallpaperBuilder:
|
|||||||
images: Sequence[Mapping[str, Path | str]],
|
images: Sequence[Mapping[str, Path | str]],
|
||||||
layout: ScreenLayout,
|
layout: ScreenLayout,
|
||||||
private_key: str | Path,
|
private_key: str | Path,
|
||||||
conf_dir: str | Path,
|
wallpaper_dir: Path,
|
||||||
search_terms: Sequence[str] | None = None,
|
search_terms: Sequence[str] | None = None,
|
||||||
exclude: Sequence[str] = (),
|
exclude: Sequence[str] = (),
|
||||||
output_path: str | Path | None = None,
|
output_path: str | Path | None = None,
|
||||||
decode_and_leave: bool = False,
|
decode_and_leave: bool = False,
|
||||||
disable_encryption: bool = False,
|
disable_encryption: bool = False,
|
||||||
) -> Path:
|
) -> tuple[Path,list]:
|
||||||
if not images:
|
if not images:
|
||||||
raise ValueError("No images are available to build a wallpaper")
|
raise ValueError("No images are available to build a wallpaper")
|
||||||
if not layout.monitors:
|
if not layout.monitors:
|
||||||
@@ -60,7 +60,7 @@ class WallpaperBuilder:
|
|||||||
encryption_manager = (
|
encryption_manager = (
|
||||||
None if disable_encryption else EncryptionManager()
|
None if disable_encryption else EncryptionManager()
|
||||||
)
|
)
|
||||||
|
images_used=[]
|
||||||
for monitor, image_record in zip(layout.monitors, selected_images):
|
for monitor, image_record in zip(layout.monitors, selected_images):
|
||||||
source = self._open_image(
|
source = self._open_image(
|
||||||
image_record,
|
image_record,
|
||||||
@@ -94,17 +94,19 @@ class WallpaperBuilder:
|
|||||||
stroke_width=1,
|
stroke_width=1,
|
||||||
stroke_fill="black",
|
stroke_fill="black",
|
||||||
)
|
)
|
||||||
|
images_used.append(image_record['name'])
|
||||||
logger.info(f"Pasted image {image_record['name']} on monitor at x={monitor.x}, width={monitor.width}, height={monitor.height}")
|
logger.info(f"Pasted image {image_record['name']} on monitor at x={monitor.x}, width={monitor.width}, height={monitor.height}")
|
||||||
|
|
||||||
destination = (
|
destination = (
|
||||||
Path(output_path)
|
Path(output_path)
|
||||||
if output_path
|
if output_path
|
||||||
else (Path(conf_dir).expanduser().resolve() / "current" / "wallpaper.jpg")
|
else (wallpaper_dir / "wallpaper.jpg")
|
||||||
)
|
)
|
||||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
canvas.save(destination, format="JPEG", quality=95)
|
canvas.save(destination, format="JPEG", quality=95)
|
||||||
logger.info(f"Wallpaper built and saved to {destination}")
|
logger.info(f"Wallpaper built and saved to {destination}")
|
||||||
return destination
|
return destination, images_used
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def find_candidates(
|
def find_candidates(
|
||||||
|
|||||||
Reference in new issue
Block a user