Remember, if you are preloading images in the Hyprpaper config, then there is no need to use the preload and unload commands in the above script.💡Here, we will use the hyprctl
command of Hyprland to manage the Hyprpaper wallpapers.A beautiful wallpaper enhances the aesthetic appeal of a desktop.
Table of Contents
What is Hyprpaper?
On Hyprland, you can use the command below to get the name of your monitor/monitors.So, in Hyprland, to switch to Workspace One, you will use the shortcut SUPER + 1. So, we set this same keybinding for a wallpaper variable.
- Per-output wallpapers
- Fill, tile or contain modes
- Fractional scaling support
- IPC for blazing fast wallpaper switches
- Preloading targets into memory
Install Hyprpaper on your Linux distribution
bind = modifier_key,desired_key,action,value
#!/bin/bash
# Wait for 5 seconds to start the script.
sleep 5
# Define daytime and nighttime image to respective variables
DAYTIME_WALLPAPER=~/Pictures/Wallpapers/3.png
NIGHTTIME_WALLPAPER=~/Pictures/Wallpapers/4.png
# Calculate the present hour and save it to a variable
PRESENT_TIME=$(date +%H)
# In an if loop, check if current time is between 6 am and 6 pm
# and assign day wallpaper to wallpaper variable.
# Else, if time is between 6 pm and 6 am,
# assign night time wallpaper to wallpaper variable.
if [ $PRESENT_TIME -ge 6 ] && [ $PRESENT_TIME -lt 18 ]; then
WALLPAPER=$DAYTIME_WALLPAPER
else
WALLPAPER=$NIGHTTIME_WALLPAPER
fi
# Preload the wallpaper in the wallpaper variable.
hyprctl hyprpaper preload "$WALLPAPER"
# Sleep 5 secconds to make sure that everything has time.
sleep 5
# Apply the wallpaper to current display.
hyprctl hyprpaper wallpaper "Virtual-1,$WALLPAPER"
# Sleep for a second
sleep 1
# Exit with success.
exit 0
In this preloading, if each wallpaper is 500KB, then a total 2.5MB of RAM will be used for preloading all this wallpaper. If you are a laptop user and IPC results in battery drain, turn it off in config using ipc = false
.But that’s the fun of it, right? Let’s see how to utilize Hyprpaper in Hyprland for your wallpaper setup.This much trouble for something as simple as wallpapers? Well, things are vastly different in the Hyprland and to the enthusiasts, this is the fun part. Doing things in a complicated manner teaches things you probably would not have learned on your own.
Using Hyprpaper
Let’s say you have preloaded all the wallpapers in Hyprpaper config and assigned the wallpaper changing commands to variables in Hyprland config, i.e. the first method in the previous section.#!/bin/bash
WALLPAPER_DIRECTORY=~/Pictures/Wallpapers
WALLPAPER=$(find "$WALLPAPER_DIRECTORY" -type f | shuf -n 1)
hyprctl hyprpaper preload "$WALLPAPER"
hyprctl hyprpaper wallpaper "Virtual-1,$WALLPAPER"
sleep 1
hyprctl hyprpaper unload unused
Since Hyprpaper is an important part of Hyprland, it should be present in the default repositories of distributions that have Hyprland present.hyprctl hyprpaper wallpaper "Virtual-1,$WALLPAPER"
preload = /path/to/image_one.png
preload = /path/to/image_two.png
preload = /path/to/image_three.png
preload = /path/to/image_four.png
preload = /path/to/image_five.png
ipc = true
hyprctl
command. If you have to change the wallpaper for another monitor, include that as well. Like:preload=path/to/wallpaper/image
wallpaper=<monitor-name>,path/to/wallpaper/image
vim .config/hypr/hyprland.conf
$wall_1 = hyprctl hyprpaper wallpaper "Virtual-1,~/Pictures/Wallpapers/1.png"
$wall_2 = hyprctl hyprpaper wallpaper "Virtual-1,~/Pictures/Wallpapers/2.png"
$wall_3 = hyprctl hyprpaper wallpaper "Virtual-1,~/Pictures/Wallpapers/3.png"
$wall_4 = hyprctl hyprpaper wallpaper "Virtual-1,~/Pictures/Wallpapers/4.png"
$wall_5 = hyprctl hyprpaper wallpaper "Virtual-1,~/Pictures/Wallpapers/5.png"
Now, using a WALLPAPER
variable, we select a random image from the directory.splash = true
This is the same as the previous section, except for key binding settings.
Add the splash text
Once the script is ready, save it as change_wallpapers.sh
. Give the script execution permission.Other than that, you can adjust the spacing of this text by using the splash_offset
percentage variable. The value is relative to the bottom. So, a 50.0 means 50% above the bottom of the monitor.bind = SUPER, 1, exec, ~/.config/hypr/change_wallpapers.sh
bind = SUPER, 2, exec, ~/.config/hypr/change_wallpapers.sh
bind = SUPER, 3, exec, ~/.config/hypr/change_wallpapers.sh
bind = SUPER, 4, exec, ~/.config/hypr/change_wallpapers.sh
bind = SUPER, 5, exec, ~/.config/hypr/change_wallpapers.sh
With Hyprpaper IPC feature, we use the hyprctl
command to preload a wallpaper. Now, the preloaded wallpaper is the one selected at random from our wallpaper directory.chmod +x change_wallpapers.sh
So, for each wallpaper, create a variable. This is not necessary, and we are doing it for convenience with the keyboard shortcuts.
Switch wallpaper with shortcuts
After that, open the Hyprland config and add a key binding to change the wallpaper at random.Hyprpaper is a Wayland wallpaper utility, which works on Hyprland and other wlroots-based compositors. This means that you can use this in other desktops like Sway, even though it is a Hyprland program.Unlike usual wallpaper managers, Hyprpaper does not have a GUI. This should not surprise you, as you are in Hyprland now.
- Preload wallpapers in Hyprpaper config and then switch fast (impacts RAM)
- Use a script to preload wallpaper and then unload when not needed.
Method 1: Preload a wallpaper and apply to workspaces
As we have seen in the first section, it is necessary to preload all the images you want to use in the Hyprpaper config file .config/hypr/hyprpaper.conf
. Also, enable ipc
.sudo dnf install hyprpaper
exec-once hyprpaper
exec-once /home/team/.config/hypr/day_night.sh
We will look into two cases:The $wall_1
is the same variable used in the previous section.First, you need to create a script, called day_night.sh
. You can create this inside the .config/hypr/
folder for easy access.Once saved, you can get a different wallpaper per workspace randomly.Add these line in your Hyprland config:Now, to change wallpaper per workspace, all you have to do is make the wallpaper key binding same as the workspace switch key binding.A basic configuration of Hyprpaper should contain the following two lines:
Method 2: Using a script to load the image
To change the wallpaper, use the general syntax:✋bind = SUPER, 1, exec, $wall_1
crontab -e
Hyprpaper expects its configuration file at .config/hypr/hyprpaper.conf
. You need to create this file to configure the program.Hyprpaper expects its configuration file at .config/hypr/hyprpaper.conf
. You need to create this file to configure the program.You can add a splash text over the wallpaper using the splash
option.
Here, you need to tweak the configuration file of Hyprpaper for necessary changes. Now, if you want to get a random wallpaper for workspace switch, use:
bind SUPER, I, exec, ~/.config/hypr/change_wallpapers.sh
Inside this file, add these lines:
Random wallpapers for different workspaces
Let’s take a look at some of its features.However, that’s not how we roll in the Hyprland. We do all sort of configuration to make it work. bind = SUPER, H, exec, $wall_1
bind = SUPER, J, exec, $wall_2
bind = SUPER, K, exec, $wall_3
bind = SUPER, B, exec, $wall_4
bind = SUPER, N, exec, $wall_5
Now, if you restart the system, there is a chance that you end up with no wallpaper. To avoid that, you can autostart your script at Hyprland startup.🚧sudo pacman -S hyprpaper
Similarly, for other workspaces too:preload=path/to/image_one
preload=path/to/image/two
wallpaper=<monitor_1-name>,path/to/image_one
wallpaper=<monitor_2-name>,path/to/image_two
sudo zypper install hyprland
bind = SUPER, 2, exec, $wall_2
bind = SUPER, 3, exec, $wall_3
bind = SUPER, 4, exec, $wall_4
bind = SUPER, 5, exec, $wall_5
To set separate wallpapers in a dual monitor setup, you must preload both the images in the configuration.
Conclusion
Let’s see the script and then identify included components.Different Wallpapers per workspace