pub struct WallpaperBuilder { /* private fields */ }
Expand description
Builder for advance Wallpaper settings and informations. This struct should not be stored for a long time, because it can become outdated if the user connect or disconnect monitors or change the Display settings.
Implementations§
Source§impl WallpaperBuilder
impl WallpaperBuilder
pub fn new() -> Result<Self, WallpaperError>
Sourcepub fn screen_count(&self) -> usize
pub fn screen_count(&self) -> usize
Return the count of active screens. This does not include disable screens.
Sourcepub fn active_screen_count(&self) -> usize
pub fn active_screen_count(&self) -> usize
Return the count of active screens. This does not include disable screens.
Sourcepub fn environment(&self) -> Environment
pub fn environment(&self) -> Environment
Return the current desktop environment.
Sourcepub fn set_wallpapers<F, P>(self, f: F) -> Result<(), WallpaperError>
pub fn set_wallpapers<F, P>(self, f: F) -> Result<(), WallpaperError>
Set background to wallpapers, witch will be selected by the given closure. The index oft screen and the current screen are passed to the closure.x
use more_wallpapers::{Mode, WallpaperBuilder};
let fallback_images = vec!["/usr/share/wallpapers/1.jpg", "/usr/share/wallpapers/2.jpg"];
let mut i = 0;
WallpaperBuilder::new()?.set_wallpapers(|screen| {
i += 1;
if i == 1 {
return ("first.jpg".to_owned(), Mode::default());
}
if screen.name == "HDMI1" {
return ("/usr/share/wallpapers/hdmi.jpg".to_owned(), Mode::Fit);
}
(
fallback_images[i % fallback_images.len()].to_owned(),
Mode::Tile,
)
})?;
Sourcepub fn set_wallpapers_from_vec<P>(
self,
wallpapers: Vec<P>,
default_wallpaper: P,
mode: Mode,
) -> Result<Vec<Utf8PathBuf>, WallpaperError>
pub fn set_wallpapers_from_vec<P>( self, wallpapers: Vec<P>, default_wallpaper: P, mode: Mode, ) -> Result<Vec<Utf8PathBuf>, WallpaperError>
Set the background of all screens to the wallpapers of wallpapers
.
The wallpaper of screen[i]
will be set to wallpapers[i mod wallpapers.len()]
.
The default_wallpaper
param is used if the given wallpapers
vec is empty and as wallpaper for inactive screens.
Return a vec, with dose inlcude the path of the Wallpapers,
witch was set as background.
If the same wallpaper was set multiple times to different screens,
the return value does also include the wallpaper multiple times.
use more_wallpapers::{WallpaperBuilder, Mode};
let images = vec!["1.jpg", "/usr/share/wallpapers/2.jpg"];
let used_wallpapers = WallpaperBuilder::new()?.set_wallpapers_from_vec(images, "default.png", Mode::Crop)?;
println!("background was set to the following wallpapers {used_wallpapers:?}");
Sourcepub fn set_random_wallpapers_from_vec<P>(
self,
wallpapers: Vec<P>,
default_wallpaper: P,
mode: Mode,
) -> Result<Vec<Utf8PathBuf>, WallpaperError>
Available on crate feature rand
only.
pub fn set_random_wallpapers_from_vec<P>( self, wallpapers: Vec<P>, default_wallpaper: P, mode: Mode, ) -> Result<Vec<Utf8PathBuf>, WallpaperError>
rand
only.Like Self::set_wallpapers_from_vec
,
but map the wallpapers randomly to the screens.
Selecting the same wallpaper multiple time will be avoid, if this is possible.