Ubuntu – How to configure a `dconf` key globally across all user accounts

automountglibgnomegsettings

I want to set the 'automount' key, for the ‘media-handling’ schema, to ‘false’, for all users on a single desktop machine.

I can do this individually, i.e. one user at a time, by using gsettings whilst logged-in as the specific user:

gsettings set org.gnome.desktop.media-handling automount false

To do this for each individual account, however, is somewhat arduous. I would like to set the same key to ‘false’ in a global fashion, so that the desired behaviour is observed globally, across all user accounts.

Using locate media-handling I have located the following ‘xml’ file:

/usr/share/glib-2.0/schemas/org.gnome.desktop.media-handling.gschema.xml

The file contains the following:

<schemalist gettext-domain="gsettings-desktop-schemas">
  <schema id="org.gnome.desktop.media-handling" path="/org/gnome/desktop/media-handling/">
    <key name="automount" type="b">
      <default>true</default>
      <summary>Whether to automatically mount media</summary>
      <description>If set to true, then Nautilus will automatically mount media such as user-visible hard disks and removable media on start-up and media insertion.</description>

I understood the files located here to be universal/global, and that any changes to these files, would affect all users globally. However, setting the value here to ‘false’ as no observable effect.

I have also found this answer and created the equivalent ‘override’ file:

/usr/share/glib-2.0/schemas$ ls | grep media-handling
org.gnome.desktop.media-handling.gschema.override.xml
org.gnome.desktop.media-handling.gschema.xml

..with the content:

[org.gnome.desktop.media-handling]
automount=”false”

I ran sudo glib-compile-schemas /usr/share/glib-2.0/schemas/ as instructed in the given answer, however there has been no observable effect. Why is this, assuming the given solution is correct?

How do I set the 'automount' key to ‘false’, in such a manner that it configures all user accounts? Once this is achieved, how do I prevent individual users from configuring their own account differently to the global rule?

Secondly, how does the system use the file /usr/share/glib-2.0/org.gnome.desktop.media-handling.gschema.xml, as my understanding would lead me to think it alters all user accounts, given its location in ….share/glib-2.0.. , however this is not the case?

(Ubuntu 16.04)

Best Answer

Do not get me wrong, but I think that here exists simpler way than editing XML-files.

You can use dconf-based profiles.
I have read about it in RedHat documentation:

Below is rough example for your problem:

sudo mkdir -p /etc/dconf/profile

cat <<EOF | sudo tee /etc/dconf/profile/user
user-db:user
system-db:local
EOF

sudo mkdir -p /etc/dconf/db/local.d

cat <<EOF | sudo tee  /etc/dconf/db/local.d/00-my
[org/gnome/desktop/media-handling]
automount=false
EOF

sudo dconf update
Related Question