Wayland environment automatically switches wallpaper
Since switching to the window manager labwc, the desktop components have been customized by myself, and the more I use it, the more I like it.
But there are two things I am not very satisfied with:
-
alt-tab
switches the active window without thumbnails, making it inconvenient to quickly select after judgment;
-
- The wallpaper software cannot automatically switch (strictly speaking, this has nothing to do with labwc, the wallpaper software is chosen by you, swaybg).
The first problem is that I usually click the mouse on the status bar to select. The disadvantage is that my hands are away from the keyboard, which affects efficiency, which is barely acceptable.
This article solves the second problem. There are actually many wallpaper programs under wayland, each of which has a different focus and the original design intention of the author.
Listed below:
-
swaybg Choose a picture as a static wallpaper
-
swww has many stars and slightly powerful functions. It can use colors as wallpapers, perform various operations on a single picture, and control the effects during the switching process. But if you want to automatically switch, you need to write a separate script.
1➜ ~ swww --help 2A Solution to your Wayland Wallpaper Woes 3 4Change what your monitors display as a background by controlling the swww daemon at runtime. Supports animated gifs and putting different stuff in different monitors. I also did my best to make it as resource 5efficient as possible. 6 7Note `swww` will only work in a compositor that implements the layer-shell protocol. Typically, wlr-roots based compositors. 8 9Usage: swww <COMMAND> 10 11Commands: 12clear Fills the specified outputs with the given color 13img Sends an image (or animated gif) for the daemon to display 14init Initializes the daemon 15kill Kills the daemon 16query Asks the daemon to print output information (names and dimensions) 17help Print this message or the help of the given subcommand(s) 18 19Options: 20-h, --help 21Print help (see a summary with '-h') 22 23-V, --version 24Print version
-
mpvpaper This is a bit outrageous. It uses mpv video playback as wallpaper. It may be suitable for corporate promotion and special groups.
-
wpaperd It is still under development. I personally choose this one because the logic is simple and clear. The key is to be able to set up a wallpaper directory (with wallpaper pictures in it) and randomly change wallpapers every once in a while. This is exactly the function I need, so I recommend this 👍.
1. Installation
- Download and compile
1$ git clone https://github.com/danyspin97/wpaperd
2$ cd wpaperd
3$ cargo build --release
- Put the program into the target PATH directory
After compilation, there will be two binary programs wpaperctl
and wpaperd
, which will be placed in /usr/local/bin
for easy calling and execution.
The former is a control program and the latter is a daemon process, which conforms to the routine and everything feels familiar.
1cp target/release/wpaperctl target/release/wpaperd /usr/local/bin
2. Configuration file
After creating the configuration file directory, adjust the configuration. My example is as follows:
1mkdir /home/mephisto/.config/wpaperd/
2➜ ~ cd .config/wpaperd
3➜ wpaperd pwd
4/home/mephisto/.config/wpaperd
5➜ wpaperd cat wallpaper.toml
6[default]
7path = "/home/mephisto/Pictures/Wallpapers/"
8duration = "30m"
9sorting = "random"
10
11[eDP-1]
12path = "/home/mephisto/Pictures/Wallpapers/"
13duration = "30m"
14sorting = "random"
15
16[DP-2]
17path = "/home/mephisto/Pictures/Wallpapers/"
18duration = "30m"
19sorting = "random"
The meaning of the above configuration is to randomly switch wallpapers every 30 minutes. The wallpaper source is the directory configured in path. Sorting also has non-random ascending and descending. I like randomness and gambling in life.
3. Set startup
In the labwc environment, it is very simple. Comment out swaybg and switch to the wpaperd daemon.
1➜ ~ head -n 5 ~/.config/labwc/autostart
2#Example autostart file
3
4# Set background color.
5# swaybg -i ~/Pictures/land.jpg >/dev/null 2>&1 &
6wpaperd >/dev/null 2>&1 &
Finally, just go to the Internet to find some good-looking wallpapers and put them into the wallpaper directory in path. The image formats support jpeg, png, webp, etc.
The final effect is that each screen randomly displays different wallpapers. Of course, you can also set it to have the same wallpaper on both screens.
In addition, you can view the currently displayed picture
1➜ ~ wpaperctl all-wallpapers
2eDP-1: "/home/mephisto/Pictures/Wallpapers/road.jpeg"
3DP-1: "/home/mephisto/Pictures/Wallpapers/th.jpeg"
For more ways to play, please check the documentation. Readers can try it themselves. I personally feel that the author understands users and has everything they need. The whole design is very simple and convenient.
4. Other knowledge
Curious babies may ask, how do you know the connection name of the monitor?
-
X11 environment, run
xrandr
-
Wayland environment, run
wlr-randr
If you are prompted that this command does not exist, you may need to install related software packages.
For example, in the wayland environment shown below, there are two screens eDP-1
and DP-1
.
1sudo apt install wlr-randr
2
3~ wlr-randr | grep -i dp
4DP-1 "Dell Inc. DELL P2417H C9G5D83N67HI (DP-1)"
5eDP-1 "Chimei Innolux Corporation 0x14C0 (eDP-1)"
eDP means embedded display, the computer comes with a screen. DP means display, external display.
Programs such as the waybar status bar and dunst desktop notifications all have configuration items that allow you to select a screen. Once you know the name, you can configure which screen to display the target information on.
Copyright statement:
- All content that is not sourced is original., please do not reprint without authorization (because the typesetting is often disordered after reprinting, the content is uncontrollable, and cannot be continuously updated, etc.);
- For non-profit purposes, to deduce any content of this blog, please give the relevant webpage address of this site in the form of 'source of original text' or 'reference link' (for the convenience of readers).
See Also:
- Gif screen recording in Wayland environment
- Application launcher yofi configuration
- Greetd and greetd tutorial
- SuperTuxKart Trial
- Why can't your kill command list the signal table
- Linux environment key detection
- Wayland environment ksnip cannot be copied problem solved
- Screenshot plus post-modification in Wayland environment
- Wofi Tutorial
- Snipe it asset management system installation and use