0

I used dconf write and gsetting set, they worked on booted GUI desktop system. I tried to run them in a script in chrooted environment and got errors. Web search found QAs for similar errors: Error spawning command line “dbus-launch --autolaunch=“xyz” --binary-syntax --close-stderr”: Child process exited with code 1, https://www.reddit.com/r/linuxquestions/comments/n90sry/error_spawning_command_line_dbuslaunch/ but former does not have an answer and in later I see cause of error different from mine.

In man pages of man 7 dconf, man dconf I did not find how to select a specific database for edit. Is there a way?

I've tried to located dconf databases on working system, but even on system where dconf write worked, $ echo $XDG_CONFIG_HOME produces empty output, /etc/dconf/profile/ does not exist, $ echo $DCONF_PROFILE produces empty output.

$ man 7 dconf
DCONF_PROFILE can specify a relative path to a file in
       /etc/dconf/profile/, or an absolute path (such as in a user's home
       directory).
A "user-db" line specifies a user database. These databases are found
       in $XDG_CONFIG_HOME/dconf/  

Added 1 (as asked in the comment by @aviro):

# Commands invoked by the script include:
dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom0/name "'Display rotate normal'"

gsettings set org.cinnamon.desktop.keybindings custom-list "['__dummy__', 'custom0', 'custom1', 'custom2', 'custom3']"

# output:
error: Error spawning command line “dbus-launch --autolaunch=XXX --binary-syntax --close-stderr”: Child process exited with code 1

(process:108725): dconf-WARNING **: 15:35:32.574: failed to commit changes to dconf: Error spawning command line “dbus-launch --autolaunch=XXX --binary-syntax --close-stderr”: Child process exited with code 1  

The script is run via sudo chroot fin_sq pathinsidenewroot/nameofscript, where new root is mounted contents of Linux Mint Cinnamon edition distro iso:

mkdir iso to temp fin 
sudo mount $original_iso iso #  -o loop
sudo mount -t overlay -o lowerdir=iso,upperdir=to,workdir=temp overlay fin
mkdir iso_sq to_sq temp_sq fin_sq
sudo mount iso/casper/filesystem.squashfs iso_sq -t squashfs -o loop
sudo mount -t overlay -o lowerdir=iso_sq,upperdir=to_sq,workdir=temp_sq overlay fin_sq  

Added 2:
Noted that whereas in "ordinary" environment both dconf read /org/cinnamon/desktop/interface/text-scaling-factor and gsettings get org.cinnamon.desktop.interface text-scaling-factor showed the same (1.0), in chrooted on that PC at about same time gsettings get showed 1.0, but dconf read output was empty. When I've changed text-scaling-factor key (in ordinary), output of gsettings get in chrooted has not changed (output of dconf read in ordinary changed to new key value).

11
  • Can you please provide more details like what does your script looks like, how exactly do you run it, what are the errors you're seeing? It's really difficult to help with so little information. From the amount of details you've provided it could be anything in the world, starting from a syntax error in your script and ending with an alien induced computer virus.
    – aviro
    Jan 23, 2022 at 7:45
  • @aviro, added, now the errors are easily reproducible (I hope). Jan 24, 2022 at 2:33
  • What are you trying to do? Why do you need to run this inside chroot environment? Is it supposed to be a sort of container? And also, what's your base OS? Is it the same like the chroot environmenr, Linux Mint Cinnamon?
    – aviro
    Jan 24, 2022 at 8:34
  • @aviro, why do you think this matters? have you tried to reproduce? It is just mounts and gsettings. Myself doing it on same LM C, you guessed correctly. Jan 25, 2022 at 5:18
  • It matters because if I'm going to try to reproduce it and to look for an answer or a solution for you, I'd would like to know it for a valid use case. Or if you're asking just for curiosity that's fine as well, but I have the right to ask, and it's customary to answer those questions. Often times people here ask questions they think will help them achieve something, while they were going in the wrong direction in the first place and there was another way for them to achieve what they wanted.
    – aviro
    Jan 25, 2022 at 7:16

1 Answer 1

2

First of all, dconf changes the configuration settings for a specific user that has X11 display running. So your first problem is that you run it as root. And even if you would attempt to switch to your own user, inside the chrooted environment your user and the groups don't appear in /etc/{passwd,group} inside the chrooted environment so it's not familiar with your user at all so you won't even be able to switch user. And even if you were able to switch (after bind mounting the relevant files from the host), you don't have your home directory in the chrooted environment. And even if you bind mounted your homedir to your chrooted environment and you can su to your user, you probably don't have your X11 sockets inside the chrooted environment and you still don't have your DBUS_SESSION_BUS_ADDRESS after the su.

You can check the answers for As root, I can use su to make dconf changes for another user. How do I actually make them apply? to see some examples on how to do find/set/use DBUS_SESSION_BUS_ADDRESS.

So you can see it's complicated enough to do this as root, and even more complicated to do that inside chrooted environment. Not impossible, but difficult. You will need to bind mount all of the relevant files/folders to the chroot folder before you even begin. That's why I asked what your use case is, and that's why I asked if you're attempting to use it as a sort of container (because some container tools, such as singularity, already do some of the work for you, like creating the relevant passwd/group, mounting your home dir, etc).

Regarding the following comment:

in chrooted on that PC at about same time gsettings get showed 1.0, but dconf read output was empty.

Both gsettings and dconf (which is actually the backend for gsettings look in $HOME/.config/dconf/user or $XDG_CACHE_HOME/dconf/user for the user's configuration. If the configuration is not found there, gsettings will look for the default settings in /usr/share/glib-2.0/schemas/gschemas.compiled.

From man glib-compile-schemas:

   glib-compile-schemas compiles all the GSettings XML schema files in
   DIRECTORY into a binary file with the name gschemas.compiled that can
   be used by GSettings. The XML schema files must have the filename
   extension .gschema.xml. For a detailed description of the XML file
   format, see the GSettings documentation.

   At runtime, GSettings looks for schemas in the glib-2.0/schemas
   subdirectories of all directories specified in the XDG_DATA_DIRS
   environment variable. The usual location to install schema files is
   /usr/share/glib-2.0/schemas.
1
  • Thanks for the answer. When asking the question IIRC I thought there is some way to edit dconf database directly or something similar. Maybe I'll try to read linked askubuntu QA for more. BTW, I'm editing liveUSB to make it boot to live session customized to my wishes. I don't know a way better than chroot to edit it. I've tried to boot with persistence but failed to find a way to merge changes back to iso file. Feb 9, 2022 at 8:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .