#wallpaper

more-wallpapers

crossplatform library to set desktop wallpaper per screen

7 unstable releases

0.4.0 Mar 29, 2024
0.3.1 Oct 31, 2023
0.3.0 Jan 4, 2023
0.2.1 Dec 8, 2022
0.1.1 Jul 5, 2022

#8 in #wallpaper

24 downloads per month
Used in konachan-wallpaper

MIT/Apache

40KB
869 lines

more-wallpapers License: MIT OR Apache-2.0 more-wallpapers on crates.io more-wallpapers on docs.rs Source Code Repository Rust Version: 1.65.0

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:

environment set wallpaper set wallpaper per screen requirements
Windows features=["fallback"]¹
MacOS features=["fallback"]¹
X11³ xwallpaper, libxrandr²
Budgie(wayland) features=["fallback"]¹
Cinnamon⁴ xwallpaper, libxrandr²
Deepin(wayland) features=["fallback"]¹
GNOME(wayland) features=["fallback"]¹
KDE
Mate(wayland) features=["fallback"]¹
Sway
XFCE

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

Dependencies

~0.4–2.1MB
~41K SLoC