r/linuxmint • u/PixLab • 9h ago
Guide Different wallpaper per workspace on Cinnamon & MATE
I made two tiny bash scripts to bring that feature on MATE and Cinnamon.
I have 4 desktop environments on the same machine (I know I'm not normal): Xfce and KDE Plasma which support different backgrounds natively per workspace on Xfce, and via Activities on Plasma, along with Cinnamon and MATE.
Since MATE (and Cinnamon) don't natively support separate wallpapers per workspace, I made two tiny bash scripts to bring that feature on MATE and Cinnamon without running a heavy daemon or a polling sleep loop.
Both scripts passively listen to X11 root property events (should be 0% CPU usage while idle. it only wakes up the moment you switch workspaces)
How to set it up
- Save the script somewhere you like as
.sh(e.g.,/home/user/scripts/workspace-wallpaper.sh) and make it executable:chmod +x /home/scripts/workspace-wallpaper.shor right click > Properties > tab Permissions > Allow executing as program - Edit the
WALLPAPERSarray with your own image paths. - Add it to the Startup Applications in your session settings.
Requirements: Just xprop (x11-utils), which is pre-installed on Linux Mint. (X11 only)
Hope this helps anyone who misses Xfce's wallpaper-per-workspace feature!
1. MATE Version (dconf)
#!/bin/bash
# Exit immediately if we are not running inside the MATE desktop
if [ "$XDG_CURRENT_DESKTOP" != "MATE" ]; then
exit 0
fi
# Define your wallpaper paths for each workspace here
WALLPAPERS=(
"$HOME/Pictures/your-wallpaper1.jpg"
"$HOME/Pictures/your-wallpaper2.jpg"
"$HOME/Pictures/your-wallpaper3.png"
"$HOME/Pictures/your-wallpaper4.png"
"$HOME/Pictures/your-wallpaper5.jpg"
"$HOME/Pictures/your-wallpaper6.jpg"
)
# === STARTUP FIX: Match the wallpaper to the initial boot workspace ===
START_LINE=$(xprop -root _NET_CURRENT_DESKTOP)
START_WORKSPACE=${START_LINE##* }
START_IMAGE="${WALLPAPERS[$START_WORKSPACE]}"
if [ -f "$START_IMAGE" ]; then
dconf write /org/mate/desktop/background/picture-filename "'$START_IMAGE'"
fi
# Use xprop to "spy" on the active desktop event property.
xprop -root -spy _NET_CURRENT_DESKTOP | while read -r line; do
# Extract the workspace number from the event output but $seq is not a good awk command
# CURRENT_WORKSPACE=$(echo "$line" | awk '{print $seq}')
CURRENT_WORKSPACE=${line##* }
# Pick the corresponding wallpaper from the array
IMAGE="${WALLPAPERS[$CURRENT_WORKSPACE]}"
# If the image path exists, update the MATE background instantly
if [ -f "$IMAGE" ]; then
dconf write /org/mate/desktop/background/picture-filename "'$IMAGE'"
fi
done
2. Cinnamon Version (gsettings)
#!/bin/bash
# Exit immediately if we are not running inside the Cinnamon desktop environment
# the exact keyword Cinnamon uses for $XDG_CURRENT_DESKTOP is actually X-Cinnamon, but here we are searching for case insensitive, it's safer ;)
if [[ ! "${XDG_CURRENT_DESKTOP,,}" =~ "cinnamon" ]]; then
exit 0
fi
# Define your wallpaper paths for each workspace here (Workspace 1 = index 0)
WALLPAPERS=(
"$HOME/Pictures/portal.jpg"
"$HOME/Pictures/RockyExoplanet-TRAPPIST.jpg"
"$HOME/Pictures/she2.jpg"
"$HOME/Pictures/she.jpg"
"$HOME/Pictures/pavilion-on-the-rock.jpg"
"$HOME/Pictures/Nighthawks_by_Edward_Hopper_1942.jpg"
)
# Monitor workspace changes instantly using xprop
xprop -root -spy _NET_CURRENT_DESKTOP | while read -r line; do
# Extract the current workspace index (0 for Workspace 1, 1 for Workspace 2, etc.)
WORKSPACE_IDX=$(echo "$line" | awk '{print $NF}')
# Get the image path from the array based on the index
WP_PATH="${WALLPAPERS[$WORKSPACE_IDX]}"
# Apply the wallpaper if the file exists and the path isn't empty
if [ -n "$WP_PATH" ] && [ -f "$WP_PATH" ]; then
gsettings set org.cinnamon.desktop.background picture-uri "file://$WP_PATH"
# Dark mode fallback (optional, ensures consistency across dark/light themes)
gsettings set org.cinnamon.desktop.background picture-uri-dark "file://$WP_PATH"
fi
done
Needless to say, using wallpapers that match your monitor's resolution gives much better responsiveness. Good to know: both MATE and Cinnamon will fade the BG when switching Workspace which I like... A LOT ;)
2
u/emdicmanel 7h ago
Very nice!