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

source

pub fn new() -> Result<Self, WallpaperError>

source

pub fn screen_count(&self) -> usize

Return the count of active screens. This does not include disable screens.

source

pub fn active_screen_count(&self) -> usize

Return the count of active screens. This does not include disable screens.

source

pub fn environment(&self) -> Environment

Return the current desktop environment.

source

pub fn screens(&self) -> &Vec<Screen>

Return a vec including all detected Screens

source

pub fn set_wallpapers<F, P>(self, f: F) -> Result<(), WallpaperError>
where P: AsRef<Utf8Path>, F: FnMut(&Screen) -> (P, Mode),

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,
	)
})?;
source

pub fn set_wallpapers_from_vec<P>( self, wallpapers: Vec<P>, default_wallpaper: P, mode: Mode ) -> Result<Vec<Utf8PathBuf>, WallpaperError>
where P: AsRef<Utf8Path>,

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:?}");
source

pub fn set_random_wallpapers_from_vec<P>( self, wallpapers: Vec<P>, default_wallpaper: P, mode: Mode ) -> Result<Vec<Utf8PathBuf>, WallpaperError>
where P: AsRef<Utf8Path> + Clone,

Available on crate feature 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.

Trait Implementations§

source§

impl Debug for WallpaperBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V