On Ubuntu Desktop 13.10, I have a setup script which runs as root. It essentially configures the computer as necessary, but I need to set some things with dconf
. The script runs in a Terminal window under a regular user with sudo
. I need to run the command dconf write /com/canonical/unity/launcher/favorites "['unity://expo-icon', <...>']"
. (It is run with a variety of different settings.)
I have tested the commands as the login user, and they work just fine. However, when I am logged in as root, I cannot do sudo -u bitc dconf write <...>
; I get errors like error: Could not connect: Connection refused
or unable to create directory '/root/.cache/conf'
.
The script must be run as root because of some other tasks it performs, but it appears that dconf
must be run under the specific login session, not just the user, to configure it. I would rather not have a separate script for dconf
, but that is possible. Is there a way to attach to the login session (or some other way to set the dconf
keys for that user)?
(The script is written in javascript with node.js.)