Running dconf in vagrant shell script

I am trying to set a powerline font as default with dconf. The following command works as expected in the vm when entered at the terminal: dconf write /org/gnome/desktop/interface/monospace-font-name "'SauceCodePro Nerd Font 9.2'"

Unfortunately it doesn’t work when the shell script with the command is executed by vagrant and because of that I suppose it is a vagrant problem.

I have tried escaping the quotes in several ways but had no luck.
Hopefully someone can help or has an idea.

As nearly always when I am asking for help I am able to solve the problem on my own :roll_eyes: It turned out that it wasn’t vagrant related.

I build a DeveloperVM with ElementaryOS as base and the VM starts with a GUI and automatically signs in the vagrant user.
Because of this all things that are necessary for running dconf like the ~/.Xauthority file and the dbus-daemon have been started for the vagrant user but not for anyone else.

To let dconf do the changes for a different user we need to use the su command with a login shell and provide all things that are necessary for dconf.

As a reference for other users that might run into the same problem I leave the two lines from my shell script here. With these two lines I am able to set the font for a user that is different to the vagrant user:

# The font that should be used
dconf_key_value=$'\"\'SauceCodePro Nerd Font 9.2\'\"'

# Set the font as default via dconf
sudo su - pna-developer --shell=/bin/bash -c "unset XAUTHORITY;xauth add $(xauth list);export \$(dbus-launch);dconf write /org/gnome/desktop/interface/monospace-font-name $dconf_key_value"