Skip to content

Conversation

@y0usaf
Copy link

@y0usaf y0usaf commented Jan 10, 2026

Add directory wallpaper support and random selection.

Addresses all feedback from PR #237 (singleton pattern, guard clauses, proper image validation, random selection approach, error message construction).

Depends on hyprwm/hyprgraphics#41

- Add support for selecting random wallpapers from directories
- Add defer_preload option to reduce memory usage
- Update README with new features
- Improve path handling with tilde expansion
- Replace <random> with helpers/RandomGenerator.hpp for consistent random number generation
- Improve buffer target handling by using path directly instead of dereferencing wallpaper target
- Simplify lambda capture in ensurePoolBuffersPresent() by using reference capture
Introduces a new ImagePicker helper that consolidates duplicate wallpaper
selection logic from Hyprpaper.cpp and ConfigManager.cpp into a single
reusable function.

- Add new ImagePicker.{hpp,cpp} with getRandomImageFromDirectory() helper
- Function handles directory scanning, file extension validation, and random selection
- Supports excluding current wallpaper to avoid duplicate selections
- Updates both wallpaper loading code paths to use the new helper
- Uses std::shuffle instead of random index for better randomization

This change improves code maintainability by removing duplicate logic and
centralizing image selection behavior in a single location.
Flattened nested conditionals into guard clauses for better readability.
vaxerski and others added 17 commits January 10, 2026 01:32
tablet-v2 was moved to stable in 1.35. Hyprpaper will fail to build if a
earlier version is used.
also updated dependencies
bumps hyprgraphics and nixpkgs
Use nixbuild/nix-quick-install-action which pairs well with
nix-community/cache-nix-action.

Should help with build times by reducing the number of packages needing
to be re-downloaded on each run.

Parameters are taken from https://github.com/nix-community/cache-nix-action
and may be tweaked later.
- Cache delimiter position to avoid repeated find_first_of() calls
- Simplify error message construction for clarity
Use try/catch to validate image files by attempting to construct them,
as isImageFile() doesn't exist in Hyprgraphics. This ensures only
loadable images are selected from directories.
Use the new isImageFile() static method from Hyprgraphics for robust
image file validation using libmagic instead of try/catch. Depends on
hyprwm/hyprgraphics#41.
@y0usaf y0usaf force-pushed the directory-wallpaper-support branch from 152baf5 to 9221db8 Compare January 10, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants