When customising your desktop, the thing that stands out the most is your wallpaper. It takes up the most pixels on your screen after all, and when it comes to setting a wallpaper on Linux on a normal desktop environment, you have more than a few options. When using a window manager, however, I find these methods easier.
If you wish to set a specific wallpaper image for each screen you have, you can use a program called “Nitrogen”.
First install it:
sudo pacman -S nitrogen
You can use Rofi to locate and launch it, Press
Super + Space, and type
The app is pretty self-explanatory, so I won’t go in depth here. It provides you with an easy-to-understand preferences window where you can add/remove wallpaper folders, choose which images to display on each screen and how they display.
You can add Nitrogen to your
autostart.sh script so that your wallpaper is set for you once you log in.
At the bottom of your
autostart.sh add the following command:
# Nitrogen wallpaper run nitrogen --restore
If you have hundreds of wallpaper images on your hard drive, and you want to set a specific folder to use for random wallpapers - the easiest way I’ve found to do this is by using feh and a Bash script.
sudo pacman -S feh
I first categorised my images into their own sub-folders like this, keeping folder names short and without using empty spaces in the names.
~/Pictures/ ├── Wallpaper/ │ ├── abstract │ ├── animals │ ├── cars │ ├── cyberpunk │ ├── fantasy │ ├── funny │ ├── nature │ ├── neon │ ├── scenic │ ├── sci-fi │ ├── space │ ├── super_hero │ ├── wallhaven
I then created a script which will allow me to choose one of those folder names using Rofi, and then have feh pick random images from that folder to use as a wallpaper.
The script will tell Rofi to present you with a list of all the subfolders contained in the path set in the
$WALLPAPERS variable. Once you select a folder name, the script will save the selected path to that folder to a file name
$HOME/.feh_walpath. This is then used by a second script which we can bind to a hotkey in sxhkd to quickly set random wallpapers.
Set Wallpaper Folder Script
If you don’t already - ensure you have exa (a ls replacement) installed.
sudo pacman -S exa
Save the script below to:
#!/usr/bin/env bash # Description: # We use exa to list only directories to Rofi, and present a list to the user to select them. # Once a folder is selected, a random image is selected for use as a wallpaper using feh, # and the selected path is output to '.feh_walpath'. # Dependencies: feh, exa, rofi # Set path to wallpaper main folder here. WALLPAPERS=$HOME/Pictures/Wallpaper/ # cd to the path provided above. cd $WALLPAPERS ## List only image sub-directories in Rofi using 'exa -D'. SELECTED=$(exa -D $WALLPAPERS|rofi -dmenu -p "Random Wallpaper Folder")&& feh --bg-max --randomize "$SELECTED"/* # Notify user that theme folder has been set. notify-send -i "/usr/share/icons/gnome/24x24/apps/preferences-desktop-wallpaper.png" "Wallpaper Theme Folder:" $SELECTED # Concatenate our main wallpaper path with the one selected by the user via Rofi, then save the path to '~/.feh_walpath' cd ~ echo $WALLPAPERS$SELECTED >$HOME/.feh_walpath
Set Wallpaper Script
Save the script below to:
#!/usr/bin/env bash # Description: # The folder path in "~/.feh_walpath" is read by "~/.scripts/feh_wallpaper_set.sh" # which then picks random images from within the folder using feh. WALLPAPERPATH=$(<$HOME/.feh_walpath) feh --no-fehbg --bg-max --recursive --randomize $WALLPAPERPATH*
Adding Wallpaper Scripts To sxhkd
We can then bind both of those scripts to hot keys by adding them to
#################### # Wallpaper #################### # Select Wallpaper Theme Folder super + e ~/.scripts/wallpaper/feh_rofi_wallpaper_select.sh # Set Random Wallpaper super + r ~/.scripts/wallpaper/feh_wallpaper_set.sh
Save the changes to your
sxhdrc file, and then reset the sxhkd daemon by pressing
Super + Shift + x.
Ensure that both scripts have execute permissions set:
cd ~/.scripts/wallpaper/ chmod +x feh_rofi_wallpaper_select.sh feh_wallpaper_set.sh
You should now be able to select a wallpaper theme folder with Rofi by pressing
Super + e. To quickly set random wallpapers from the last selected theme folder, press
Super + r.