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
try:
os.mkdir(os.path.join(os.environ["HOME"], ".config/wswitcher"))
except FileExistsError:
pass
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]]
).decode("utf-8").strip()
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:
time.sleep(1)
currwall2 = getwall()
curr_ws2 = current_ws()
datafile = workspace_data+curr_ws2
if curr_ws2 == curr_ws1:
if currwall2 != currwall1:
open(datafile, "wt").write(currwall2)
else:
if not os.path.exists(datafile):
open(datafile, "wt").write(currwall2)
else:
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
- Copy the script into an empty file
- Save it as
wallswitcher.py
Test- run it by the command:
python3 /path/to/wallswitcher.py
- Then simply start setting up your wallpapers as demonstrated here.
If all works fine, add it to Startup Applications:
/bin/bash -c "sleep 10 && /path/to/wallswitcher.py
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.echo $DESKTOP_SESSION
?