Desktop wallpaper switcher for Linux Mint

Those of you who have used Mac know that having ability to set different wallpapers for each of your workspaces is a nice feature.

Unfortunately such feature is not [always] available in Linux.

But, turns out that you can easily add this feature on your own.

Your system already has the utility xprop, which allows you to monitor your desktop parameters, and gsettings, which let you change desktop configuration on the fly. You just need a simple script to tie all that together. Feel free to copy the code below:

#!/bin/bash
 #
 # This script runs in background, waiting for you to switch to
 # another workspace, so that it can change the desktop wallpaper
 # accordingly when you do.
 #
 # Tested on Linux Mint 18 Mate
 #
 # Script by crcok from:
 # https://crcok.wordpress.com/2016/09/14/wallpaper-switcher-mint/
 # Based on the script by garolou from:
 # https://forums.linuxmint.com/viewtopic.php?t=118540#p672189
 #
 # If you know how to make Linux Mint Mate display a different set
 # of desktop icons for each of the workspaces, please come to
 # https://crcok.wordpress.com/2016/09/14/wallpaper-switcher-mint/
 # and share your ideas in comments.
 #

# Edit this. Your wallpaper directory. Don't forget the trailing slash.
 desktop_dir="/home/user/.wallpapers/"

# Edit this. Wallpaper image file names. One for each workspace you are using.
 desktop_img[0]="wallpaper01.jpg"
 desktop_img[1]="wallpaper02.jpg"
 desktop_img[2]="wallpaper03.jpg"
 desktop_img[3]="wallpaper04.jpg"

# This is a function nicely encapsulating a call to the desktop.
 # Note that it is Mate and not Gnome we are talking to here.
 setdesktop() {
 gsettings set org.mate.background picture-filename "$desktop_dir$1"
 }

# The main loop. Every time you change to another workspace,
 # xpropr will output its number and thus will trigger the change.
 xprop -root -spy _NET_CURRENT_DESKTOP | (
 while read -r; do
 desk=${REPLY:${#REPLY}-1:1}
 setdesktop ${desktop_img[$desk]}
 done
 )
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s