Crate more_wallpapers

source ·
Expand description

Yet another wallpaper crate, which can set a wallpapers per screen.

The main feature over other crates like wallpaper or wall is the ability to set different wallpapers on different screens. Currently this feature is only implemented for some environments. Because of this you can enable the fallback feature, to use a custom version of the wallpaper crate as a fallback on unsupported environments. This means you can use the additonal features of this crate and still support a large amount of environments.

Currently the following environments are supported:

environmentset wallpaperset wallpaper per screenrequirements
Windowsfeatures=["fallback"]¹
MacOSfeatures=["fallback"]¹
X11³xwallpaper, libxrandr²
Budgie(wayland)features=["fallback"]¹
Cinnamon⁴xwallpaper, libxrandr²
Deepin(wayland)features=["fallback"]¹
GNOME(wayland)features=["fallback"]¹
KDE
Mate(wayland)features=["fallback"]¹
Swayfeatures=["fallback"]¹

¹ Please check also the requirements of the wallpaper crate.
² Normally already installed.
³ Wallpapers will be reset after restart.
⁴ Wallpapers will be reset to provided default after restart.

The information about the currently supported features are also provided by the Environment enum.

QuickStart / Examples:

If you would like to set only a different wallpaper for each screen and don’t care which wallpaper is used on which screen, you can use set_wallpapers_from_vec() or set_random_wallpapers_from_vec() (only aviable with the rand feature):

use more_wallpapers::Mode;

let images = vec!["1.jpg", "/usr/share/wallpapers/2.jpg"];
more_wallpapers::set_wallpapers_from_vec(images, "default.jpg", Mode::Crop)?;

The "default.jpg" is used as wallpaper for inactive screens. If you do not know witch value you shoud use here, you can simple use the first elment of the images vec.

For advanced wallpaper settings you can use the WallpaperBuilder:

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

Modules

Structs

include information about a connected screen
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.

Enums

Represent the used operating system or desktop. Inform about supported features, at the curren environment.
define how the wallpaper will be stretch, zoom, repeated etc

Functions

Like 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.
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.