reujab / wallpaper.rs Goto Github PK
View Code? Open in Web Editor NEWA cross-platform Rust library for getting and setting desktop wallpapers
License: The Unlicense
A cross-platform Rust library for getting and setting desktop wallpapers
License: The Unlicense
It would be great to be able to change the wallpaper of the lock screen on the OSs that support it.
PS. Do you know any cross-platform library that does the same thing?
I am myself developing a crate to create wallpapers, and as it is now I feel reluctant to use wallpaper
as a dependency because the set_from_url
pulls in many dependencies which I am not using (I only need the set_from_path
function), and I would feel bad forcing my users to compile reqwest
, url
and all of their many dependencies.
Apart from this single drawback, wallpaper
is the best crate of its kind that I could find, and I would love for it to be a bit more lightweight for my use-case.
Case in point:
$ cd wallpaper.rs
$ cargo tree | wc -l
312
I know that there are duplicates, but this is still a bit much.
Proposal: make reqwest
and url
optional dependencies. Of course, they would be opt-out to avoid breaking any other crates.
If this proposal seems reasonable to you, I already have a pull request ready that implements it by adding a "from-url"
feature enabled by default and that one can opt out of:
$ cd wallpaper.rs
$ cargo tree --no-default-features | wc -l
5
For macos 14, default wallpaper is /System/Library/CoreServices/DefaultDesktop.heic
, wallpaper::get()
return Err("osascript exited with status code 1")
osascript -e 'tell application "System Events" to picture of current desktop'
It would be a nice feature, if it is possible to set different wallpaper on different screens.
can we get a get_mode()
implementation which checks and returns the wallpaper mode
I'm trying to run this minimal example
use wallpaper;
fn main() {
wallpaper::set_from_path(
"<private>/t3_reaw76.jpeg",
)
.unwrap()
}
but it doesn't set the new background even though the image exists an can be set manually.
Linux: 5.15.46-1
rust: stable @ 1.61.0 (2022-05-18)
<gnome-version>
<platform>42</platform>
<minor>2</minor>
<micro>0</micro>
<distributor>Arch Linux</distributor>
<!--<date></date>-->
</gnome-version>
This simple example does not change my background:
fn main() {
wallpaper::set_from_path("/home/septias/Pictures/wallpapers/t3_10aryph.png");
}
On macOS, the set_from_path
function only sets the wallpaper of the desktop that's currently in the foreground. If a fullscreen app is active, nothing happens.
When I try to change the wallpaper in XFCE (Arch Linux) I get this error:
thread 'main' panicked at 'called
Result::unwrap()on an
Err value: "xfconf-query exited with status code 1"', src/libcore/result.rs:1084:5
This is because this library uses this command to change the wallpaper in XFCE: xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s PATH
, but in Arch (I do not know other OS) the property is /backdrop/screen0/monitorLVDS1/workspace0/last-image
instead of /backdrop/screen0/monitor0/workspace0/last-image
It looks like that the current master is broken on windows and mac:
❯ cargo check --target x86_64-apple-darwin
Checking wallpaper v4.0.0 (https://github.com/reujab/wallpaper.rs.git#20270387)
Checking clap v3.2.23
error[E0433]: failed to resolve: use of undeclared crate or module `ini`
--> /home/lukas/.cargo/git/checkouts/wallpaper.rs-e56f8913492c51cc/2027038/src/error.rs:14:24
|
14 | InvalidIni(#[from] ini::ini::Error),
| ^^^ use of undeclared crate or module `ini`
error[E0412]: cannot find type `Path` in this scope
--> /home/lukas/.cargo/git/checkouts/wallpaper.rs-e56f8913492c51cc/2027038/src/macos.rs:20:14
|
20 | P: AsRef<Path> + std::fmt::Display,
| ^^^^ not found in this scope
|
help: consider importing this struct
|
1 | use std::path::Path;
|
error[E0308]: mismatched types
--> /home/lukas/.cargo/git/checkouts/wallpaper.rs-e56f8913492c51cc/2027038/src/macos.rs:28:39
|
18 | pub fn set_from_path<P>(path: P) -> Result<()>
| - this type parameter
...
28 | enquote::enquote('"', path),
| ---------------- ^^^^ expected `&str`, found type parameter `P`
| |
| arguments to this function are incorrect
|
= note: expected reference `&str`
found type parameter `P`
note: function defined here
--> /home/lukas/.cargo/registry/src/github.com-1ecc6299db9ec823/enquote-1.1.0/src/lib.rs:19:8
|
19 | pub fn enquote(quote: char, s: &str) -> String {
| ^^^^^^^
Some errors have detailed explanations: E0308, E0412, E0433.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `wallpaper` due to 3 previous errors
❯ cargo check --target x86_64-pc-windows-gnu
Checking wallpaper v4.0.0 (https://github.com/reujab/wallpaper.rs.git#20270387)
Checking clap v3.2.23
error[E0433]: failed to resolve: use of undeclared crate or module `ini`
--> /home/lukas/.cargo/git/checkouts/wallpaper.rs-e56f8913492c51cc/2027038/src/error.rs:14:24
|
14 | InvalidIni(#[from] ini::ini::Error),
| ^^^ use of undeclared crate or module `ini`
error[E0433]: failed to resolve: use of undeclared crate or module `enquote`
--> /home/lukas/.cargo/git/checkouts/wallpaper.rs-e56f8913492c51cc/2027038/src/error.rs:17:21
|
17 | Enquote(#[from] enquote::Error),
| ^^^^^^^ use of undeclared crate or module `enquote`
For more information about this error, try `rustc --explain E0433`.
error: could not compile `wallpaper` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Linux does work fine.
When I add a command to cron
attempt to change wallpaper automatically, but it failed.
My OS is Ubuntu Linux.
Please fixed this issue.
Currently for gnome dark mode, I am having to point to this git repository - it would be pretty helpful if you pushed 4.0.0 to crates.io
:)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.