How to store a dconf key as read-only?

I want to use Unity-2D's Dodge feature for the dash. I accomplished that by changing the hide-mode value in com.canonical.Unity2d.Launcher in DConf Editor to 2.

However, when I decide to change Ubuntu's wallpaper, the hide-mode value gets reverted to 0. I want to prevent this by making the setting hide-mode read-only. How can I do this?


Solution 1:

The directory you need for this is

/etc/dconf/db/local.d/locks

The are not stored there though; this is the place to put them to make one read-only. From dconf admininstration ...

Lockdown

Lockdown is supported by creating a 'locks' subdirectory in the keyfile directory (ie: /etc/dconf/db/local.d/locks). The files contained in this directory contain a list of keys to lock, one per line. Just as with the keyfiles, you may add any number of files to this directory. Here's an example of what one might look like:

# prevent changes to the company wallpaper
/org/gnome/desktop/background/picture-uri

Of course, you need to run the 'dconf update' tool after changing the locks. The tool will notice if the timestamp on the 'locks' directory has changed, so there is no need to touch the ".d" directory as well.


  • The lockdown key for hide-mode should be ...

     /com/canonical/unity-2d/launcher/hide-mode
    

    I would consider it a bug if this does not work.

Alternative ...

  • Command line method:

     dconf write /com/canonical/unity-2d/launcher/hide-mode 1
    

You could add this to some script or ~/bashrc or something else to get it reset.


18.04 used gdm3.

DConf configuration

Some GDM settings are stored in a DConf database. They can be configured either by adding keyfiles to the /etc/dconf/db/gdm.d directory and then recompiling the GDM database by running dconf update as root or by logging into the GDM user on the system and changing the setting directly using the gsettings command line tool. Note that for the former approach, a GDM profile file is required - this must be created manually as it is no longer shipped upstream, see below:

/etc/dconf/profile/gdm
user-db:user
system-db:gdm
file-db:/usr/share/gdm/greeter-dconf-defaults

In /etc/dconf/db/gdm.d you can create a file per key in the sty

rinzwind@schijfwereld:/etc/dconf/db/gdm.d$ ls
02-logo
rinzwind@schijfwereld:/etc/dconf/db/gdm.d$ more 02-logo 
[org/gnome/login-screen]
logo='/discworld/Pictures/Wallpapers/Nier.9.jpg'

And this will preseed the value in dconf.

More examples in the link.