Autorandr (screen setup) on startup/login

I’ve setup an autorandr config that sets up my desktop screens/scaling (I have two screens with different resolutions) - is there a way to have this ran on login and/or startup?

Previously on an Arch system I had this in an xorg configuration file, but I could not determine if this was possible in nixos.

Thanks in advance.

Yes, there is. Details depend on whether you use HM or not, and which WM/DE you use and whether you are on X or Wayland.

As a rule of thumb: the same solution you had on Arch should work for NixOS as well, but there are things that affect how to apply it.

For now I’m continuing to use X with Plasma. Installing home manager is next on my task list!

Then just do what you did on Arch, assuming it was editing ~/.xsession.

Well - on my arch system I actually did it via an xorg.conf file. However, I couldn’t find any particular way to do this on a search.

Unfortunately the ~/.xession did not work.

Feeling stupid now… I found how to write the xorg files now decoratively using environment.etc.

I’m going to launch another thread for help on getting this xorg setup that I want.

Hi @JonBoyleCoding ,

I was trying to fo the same thing but not really sure what you did with the environment.etc…

Would you share your configuration on how you were able to get this to run on startup?

Thanks

Unfortunately I wasn’t able to get it to work on startup in the end. I figured out how to get my xorg configuration working for startup which worked for me as it’s mostly a static startup. I can’t access that machine right now though so I can’t provide any configuration to help for a few days.

Hey mate,

No worries, thanks for the update. Ill wait fot the xorg.config.

btw, Im not sure if you us home manager and saw https://mynixos.com/home-manager/option/xsession.initExtra. Ive only read about it online and hope to try it out soon.

Thanks

Sorry for the late update.

This is how I’m setting this for the moment for my NVIDIA gpu.

  services.xserver = {
    deviceSection = ''
      VendorName "NVIDIA Corporation"
    '';

    screenSection = ''
      Option "metamodes" "DP-4: 1920x1080+1920+0, DP-0.8: 1920x1080+0+0"
    '';

    exportConfiguration = true;

    videoDrivers = [ "nvidia" ];
  };

  # Setup NVIDIA drivers
  hardware.opengl.enable = true;
  hardware.nvidia.modesetting.enable = true;

Don’t know if it’ll be of any use for you, but maybe it will be for someone else if not.

I hope I didn’t miss anything obvious here but there is a service for autorandr.

In home-manager is a service for a tool called grobi which I started to use because I autorandr gave me problems.

1 Like

I finally got back to looking at this again - I managed to get grobi working with my setup! Plus it also helped solve an issue with one of my screens that gets stuck in limbo sometimes when it goes into standby.