All entries for Friday 15 May 2015

May 15, 2015

Because 'dconf update' looks at modification time of directory not files

Are you making modifications to a dconf profile, running 'dconf update' and wondering why the settings aren't applying? I was. And this is why…


I have some dconf settings that I want to set conditionally and that's done by writing relevant value to a file like this:

#!/bin/bash

F=/etc/dconf/db/foo.d/blah

if [ "$(something)" = "yes" ];then
   V='true';
else
   V='false';
fi

cat > "${F}" << EOF
[what/ever/]
key=${V}
EOF

dconf update

/etc/dconf/db/foo.d/blah was getting updated, but the setting wasn't being applied. I noticed the binary database /etc/dconf/db/foo wasn't being updated, which was evident by the modification time stamp not changing after 'dconf update' was run.

Eventually I discovered that 'dconf update' doesn't look at the file modification times, it looks at the modification time of the directory containing the files. See https://bugzilla.gnome.org/show_bug.cgi?id=708258 Changing the contents of the file by writing to it with cat doesn't cause the modification time of the enclosing directory to change. So I needed to also change the modification time of foo.d, which can be done with touch

#!/bin/bash

F=/etc/dconf/db/foo.d/blah

[ as above cut for brevity ]

touch $(dirname ${F})
dconf update

With that additional touch command, things started to work as desired.


Search this blog

Tags

Not signed in
Sign in

Powered by BlogBuilder
© MMXXIV