I know this has been answered before but that solution doesn't work on Ubuntu MATE. Anyway to achieve this on MATE?

Output of wmctrl -d:

$ wmctrl -d
0  * DG: 1366x768  VP: 0,0  WA: 0,25 1366x719  Workspace 1
1  - DG: 1366x768  VP: N/A  WA: 0,25 1366x719  Workspace 2
2  - DG: 1366x768  VP: N/A  WA: 0,25 1366x719  Workspace 3
3  - DG: 1366x768  VP: N/A  WA: 0,25 1366x719  Workspace 4

Output of $ echo $DESKTOP_SESSION:


Original solution that I tried and that didn't work for me:
Is it possible to have a different background for each workspace?

  • Please add a link to the solution that doesn't work in order to show what you tried.
    – simlev
    Aug 10, 2017 at 19:57
  • I could edit this one askubuntu.com/questions/305468/… (launchpad.net/~vlijm/+archive/ubuntu/wswitcher) to work with mate, but please add the output of wmctrl -d to your question, to make sure how mate handles workspaces (I don't run Mate). Currently, the application works for Unity and Budgie. Aug 10, 2017 at 20:25
  • @JacobVlijm I have added the output Aug 10, 2017 at 21:02
  • @simlev I added the link Aug 10, 2017 at 21:04
  • Cool! that means the code just needs a tiny edit. I forgot one thing: could you also post the exact output of echo $DESKTOP_SESSION? Aug 10, 2017 at 21:11

2 Answers 2


Although I could not test it, due to the fact that I don't have Mate avaialble atm, looking at the output of wmctrl -d, and given the fact that wallpapers on Mate are obviously set with the same gsettings command, I see no reason why it should not work.

The script

The script below is an edited version of this one, and kind of an exerpt of the one I pushed to Launchpad. As it is, that one won't work for Mate, since I added a session-check in that one, for either Unity or Budgie.

If you can confirm the script below works on Mate, I'll probably edit the ppa version to include Mate.

The script

#!/usr/bin/env python3
import subprocess    
import os
import time

    os.mkdir(os.path.join(os.environ["HOME"], ".config/wswitcher"))
except FileExistsError:

workspace_data = os.environ["HOME"]+"/.config/wswitcher/wallpaper_data_"
key = [
    "gsettings get ",
    "gsettings set ",
    "org.gnome.desktop.background picture-uri",

def getwall():
    return subprocess.check_output(
        ["/bin/bash", "-c", key[0]+key[2]]

def get_res():
    # get resolution
    xr = subprocess.check_output(["xrandr"]).decode("utf-8").split()
    pos = xr.index("current")
    return [int(xr[pos+1]), int(xr[pos+3].replace(",", "") )]

def current_ws():
    # get the current workspace
    wsdata = subprocess.check_output(["wmctrl", "-d"]).decode("utf-8").splitlines()
    return [l.split()[0] for l in wsdata if "*" in l][0]

def wswitcher(curr_ws1, currwall1):
    while True:
        currwall2 = getwall()
        curr_ws2 = current_ws()
        datafile = workspace_data+curr_ws2
        if curr_ws2 == curr_ws1:
            if currwall2 != currwall1:
                open(datafile, "wt").write(currwall2)
            if not os.path.exists(datafile):
                open(datafile, "wt").write(currwall2)
                curr_set = open(datafile).read()
                command = key[1]+key[2]+' "'+str(curr_set)+'"'
                subprocess.Popen(["/bin/bash", "-c", command])
        curr_ws1 = curr_ws2
        currwall1 = getwall()

curr_ws1 = current_ws(); currwall1 = getwall()
wswitcher(curr_ws1, currwall1)

How to use

  1. Copy the script into an empty file
  2. Save it as wallswitcher.py
  3. Test- run it by the command:

    python3 /path/to/wallswitcher.py
  4. Then simply start setting up your wallpapers as demonstrated here.
  5. If all works fine, add it to Startup Applications:

    /bin/bash -c "sleep 10 && /path/to/wallswitcher.py

The solution proposed by Jacob Vlijm works fine on my Mate, provided that I change org.gnome.desktop.background picture-uri to org.mate.background picture-filename in the script (information found here).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.