GDM monitor configuration

Hello,

Since /run/gdm is created from a blank slate on restart of the system, how could I make a local tweak so that GDM uses the same monitor configuration (scale and monitor arrangement, I have multiple monitors) as my user account?

On other Linux distributions, I would have done it by manually copying ~/.config/monitors.xml to the GDM home folder (/run/gdm on nixOS), but that obviously is a bit ugly and frowned upon.

I tried to see how I could override attributes on gdm.nix with overlays and overrideAttrs, but I was not successful (I wanted to add an environment.etc.“gdm/monitors.xml” block to dump my local monitors configuration into.

How can I make the least amount of changes (happy to create a little GDM fork), and get a nice 200% scale on GDM login screen as well as the right monitors being primary?

Ideally this would be exposed via some settings of the GDM module rather than hacks.

Thanks!

1 Like

Hey oberstal,

I ran into this myself after getting frustrated with GDM always trying to display on the TV I have plugged in (which is usually off) rather than my main monitor. Digging around in gdm.nix I noticed there is already a pulseaudio config being symlinked into /run/gdm using systemd.tmpfiles.rules and figured that pattern would work for monitors.xml as well.

Here’s what I have in my configuration.nix and it seems to be working well:

  systemd.tmpfiles.rules = [
    "L+ /run/gdm/.config/monitors.xml - - - - ${pkgs.writeText "gdm-monitors.xml" ''
      <!-- this should all be copied from your ~/.config/monitors.xml -->
      <monitors version="2">
        <configuration>
            <!-- REDACTED -->
        </configuration>
      </monitors>
    ''}"
  ];

Here is where the tmpfiles are set up in gdm.nix, if you’re curious: https://github.com/NixOS/nixpkgs/blob/cd63096d6d887d689543a0b97743d28995bc9bc3/nixos/modules/services/x11/display-managers/gdm.nix#L152-L160

1 Like

Update: I opened a nixpkgs PR to add a services.xserver.displayManager.gdm.monitorsConfig option for this.

1 Like

I faced the same issue. However rather than having two different config one at system level and another one at user level, I wanted the user level monitors.xml to drive the settings. For that reason I ended up reading the user level monitors.xml as in the configuration.nix file as show below:

{  config, pkgs, ... }: 

let

  monitorsXmlContent = builtins.readFile /home/REPALCE_WITH_USERNAME/.config/monitors.xml;
  monitorsConfig = pkgs.writeText "gdm_monitors.xml" monitorsXmlContent;
in

followed by

  systemd.tmpfiles.rules = [
    "L+ /run/gdm/.config/monitors.xml - - - - ${monitorsConfig}"
  ];