I have an installation script that customises the target machine by running about two-dozen gsettings set
commands. Trouble is, that only works if you run the command as the right user. If you run it as root, it doesn't work at all.
So I invented a script function that looks like this:
function GSET
{
echo "gsettings set '$1' '$2' '$3'"
sudo -u mango dbus-launch gsettings set "$1" "$2" "$3"
}
The script then calls this function several dozen times, which seems to work (i.e., the settings actually change now), and all is good.
Well, not quite: If I run this on the machine I'm trying to configure, it seems to work great. If I try to run it on our build server in a chroot
environment to create an installation image... The server now has a dozen dbus-daemon
processes running on it. And every time I run a new installation build, I'm left with more and more of these useless processes running, until eventually the server exhausts some kind of resource (PIDs or something), and gsettings
stops working completely.
So, my question: What is the correct way to make gsettings
work? I saw another answer somewhere that suggested adding the --exit-with-session
switch, but that just stopped the command working at all. Is there some way to launch a single daemon for all the settings and then stop it afterwards or something?