LightDM doesn't show the user background

New version of my script to be compatible with the new way LightDM handles user backgrounds starting with Ubuntu MATE 18.04:

#!/bin/bash
#
# Sets the following:
# [org.freedesktop.DisplayManager.AccountsService]
# BackgroundFile
# [User]
# Background
# in /var/lib/AccountsService/users/$USER

function setuserbackground(){
	export USERBACKGROUND=`gsettings get org.mate.background picture-filename | tail -c +2 | head -c -2`

	dbus-send --system --print-reply \
	--dest=org.freedesktop.Accounts \
	--type=method_call \
	/org/freedesktop/Accounts/User`id -u` \
	org.freedesktop.Accounts.User.SetBackgroundFile string:"$USERBACKGROUND"

	dbus-send --system --print-reply \
	--dest=org.freedesktop.Accounts \
	/org/freedesktop/Accounts/User`id -u` \
	org.freedesktop.DBus.Properties.Set \
		string:org.freedesktop.DisplayManager.AccountsService \
		string:BackgroundFile \
		variant:string:"$USERBACKGROUND"
}

setuserbackground

dbus-monitor --profile "type='signal',interface='ca.desrt.dconf.Writer',path='/ca/desrt/dconf/Writer/user',arg0path='/org/mate/desktop/background/'" |
while read -r line; do
	setuserbackground
done

I’ve put a deb on a Dropbox account if you want to install/uninstall it easily: https://www.dropbox.com/s/zmf5sf7t11v0zdv/msd-background-helper_0.7_all.deb?dl=0

It’s probably badly made and might trigger Lintian errors but it works. Before installing it, delete the script in /usr/bin and the .desktop in /etc/xdg/autostart if you used the previous version.