# Running dconf in vagrant shell script

**URL:** <https://discuss.hashicorp.com/t/running-dconf-in-vagrant-shell-script/23148>\
**Category:** Vagrant\
**Created:** [April 14, 2021, 3:05pm UTC](https://discuss.hashicorp.com/t/running-dconf-in-vagrant-shell-script/23148 "2021-04-14T15:05:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gremlin-master](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/gremlin-master/32/18628_2.png) [@gremlin-master](https://discuss.hashicorp.com/u/gremlin-master)\
**Post date:** [April 14, 2021, 3:05pm UTC](https://discuss.hashicorp.com/t/running-dconf-in-vagrant-shell-script/23148/1 "2021-04-14T15:05:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gremlin-master](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/gremlin-master/32/18628_2.png) [@gremlin-master](https://discuss.hashicorp.com/u/gremlin-master)\
**Post date:** [April 15, 2021, 2:04pm UTC](https://discuss.hashicorp.com/t/running-dconf-in-vagrant-shell-script/23148/2 "2021-04-15T14:04:19Z")

</div>

As nearly always when I am asking for help I am able to solve the problem on my own 🙄 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:

```bash
# 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"

```
