I want to use my laptop (Ubuntu with Nix via home-manager) with varying screen resolutions (using autorandr). That means that I want to change the value of the Gdk/WindowScalingFactor setting (and others) when plugging in a different monitor. I’m using xsettingsd, which AIU would involve changing the configuration file and sending a HUP signal (or restarting the systemd service).
Now, with Nix the config file lives in the store and is readonly. I was considering using a read-write copy of the configuration file, but that seems hard to integrate with the home-manager support for xsettingsd (here).
Try using xfsettingsd instead. I switch manually between light as dark themes using xsettings, and I do it using xsettingsd and xfconf-query. You’re welcome to have a look at my home.nix.
Thanks for the tip! Unfortunately I didn’t manage to get xfsettingsd to work. Is that supposed to be used without the rest of XFCE?
>> xfsettingsd
Failed to connect to session manager: Failed to connect to the session manager: SESSION_MANAGER environment variable not defined
(xfsettingsd:481155): xfsettingsd-CRITICAL **: 08:15:48.091: Failed to save xfconf property /general/workspace_names
>> xfsettingsd --sm-client-disable
(xfsettingsd:481205): xfsettingsd-CRITICAL **: 08:16:00.280: Failed to save xfconf property /general/workspace_names
>> xfconf-query -c test -p /test1 -n -t int -s 1
Failed to set property.
I am using it outside of XFCE. I’m running i3wm. For what it’s worth, that environment variable is not set for me either. As you can see from my config, I’m running it as a systemd service:
❯ s --user status xfsettingsd.service
● xfsettingsd.service - xfsettingsd
Loaded: loaded (/home/zeorin/.config/systemd/user/xfsettingsd.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-07-30 18:35:38 SAST; 2h 17min ago
Main PID: 1753 (.xfsettingsd-wr)
Tasks: 10 (limit: 18875)
Memory: 26.4M
CPU: 551ms
CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/xfsettingsd.service
└─1753 /nix/store/ffp0ysjiaw0xgb56bsnj7hispwc1724l-xfce4-settings-4.16.2/bin/xfsettingsd
Jul 30 18:35:38 monarch systemd[1673]: Started xfsettingsd.
Jul 30 18:35:38 monarch .xfsettingsd-wr[1753]: AT-SPI: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.Servic>
Jul 30 18:35:39 monarch xfsettingsd[1753]: Failed to connect to session manager: Failed to connect to the session manager: SESSION_M>
Jul 30 18:35:44 monarch xfsettingsd[1753]: xfsettingsd: No window manager registered on screen 0.
Jul 30 18:35:48 monarch .xfsettingsd-wr[1753]: Failed to set property "xfwm4::/general/workspace_count": Operation was cancelled
Jul 30 18:35:49 monarch .xfsettingsd-wr[1753]: Failed to set property "xfwm4::/general/workspace_count": Operation was cancelled
Jul 30 18:35:50 monarch .xfsettingsd-wr[1753]: Failed to set property "xfwm4::/general/workspace_count": Operation was cancelled
Jul 30 18:35:50 monarch .xfsettingsd-wr[1753]: Failed to set property "xfwm4::/general/workspace_count": Operation was cancelled
Seems I’m getting the same errors that you are, but that doesn’t stop it from working in my case:
❯ xfconf-query -c test -p /test1 -n -t int -s 1
❯ xfconf-query -c test -p /test1
1
Ok, some more debugging explains why it was working for some time and then wasn’t: It was working as long as the Ubuntu xfconf package was installed. For some reason nix xfconf-query starts xfconfd from that package, and can’t find it’s own if not.
I’m unsure how xfconfd should get started. I’m getting the impression that this is somehow related to D-Bus, but I have no clue how that fits together…