jistr / ansible-gsetting

Ansible module for setting GSettings entries
Apache License 2.0
47 stars 18 forks source link

cannot change settings with desktop-specific defaults #19

Open yakshaver2000 opened 1 year ago

yakshaver2000 commented 1 year ago

On a Debian 11 system, I found that the following code had no effect:

- gsetting:
    user: jrandom
    settings:
      org.gnome.mutter.focus-change-on-pointer-rest: "false"

This happens because the default value of some GSettings depends on the environment variable XDG_CURRENT_DESKTOP.

When ansible-gsetting invokes gsettings for another user, XDG_CURRENT_DESKTOP is unset. On my (Debian 11) system, that makes the default value of the focus-change-on-pointer-rest setting false. So ansible-gsetting decides to do nothing.

When my user jrandom is logged in, however, XDG_CURRENT_DESKTOP is set to the value GNOME, which changes the default of focus-change-on-pointer-rest to true. So now the effective setting for jrandom is the opposite of what's in the playbook.

You can see the difference in behaviour of gsettings here:

$ gsettings reset org.gnome.mutter focus-change-on-pointer-rest
$ echo $XDG_CURRENT_DESKTOP
GNOME
$ gsettings get org.gnome.mutter focus-change-on-pointer-rest
true
$ unset XDG_CURRENT_DESKTOP
$ gsettings get org.gnome.mutter focus-change-on-pointer-rest
false
$

(I guess that happens because there is a [org.gnome.mutter:GNOME] section in /usr/share/glib-2.0/schemas/00_org.gnome.shell.gschema.override which modifies the defaults of a handful of settings.)

yakshaver2000 commented 1 year ago

Initially, I thought that this could be fixed by modifying ansible-gsetting such that its settings take effect regardless of the user's current value of XDG_CURRENT_DESKTOP. To do that, though, we would need a way to check if a particular setting has been explicitly set or is following the default value. The gsettings tool doesn't seem to provide any way to do that.

So maybe I'm misunderstanding how gsettings should be used and

  1. If I want to configure things "for all desktop environments", I should be using dconf (and ansible-dconf) instead of gsettings.
  2. A worthwhile improvement to ansible-gsetting would be to add a new module parameter that lets me specify the XDG_CURRENT_DESKTOP I'm expecting the user to set.