linuxrpmrpm-spec

RPM build, can I change gsettings in %post?


After installing an rpm package that I built I would like to change some gsettings. I tried doing so in the %post section, but it does not do anything during the install (not even fail).

spec file:

...
%post
echo "test post"
gsettings set org.gnome.desktop.interface cursor-theme 'something-else'

The echo works, and if I manually type the gsettings command into the terminal it works, but during the installation the command does not work. Any ideas?


Solution

  • Aaron is correct in their comment: Even if you can successfully run gsettings in your %post script, you'll be changing settings for the root user.

    If you want to change configurations for some other user in an automated fashion, you could drop a script into /etc/profile.d; these scripts are run for new login shells, which will include someone logging into an X session.

    You would want to add some conditionals around your gsettings statement to ensure that it only runs successfully once: if it runs on every login, you've made it impossible for someone to undo this particular configuration change, which can be a frustrating experience.

    I would argue that this is better solved via documentation ("After installing this package, here's how to activate the new cursor theme...").