{ config, pkgs, ... }:
{
  config.home.niri.settings.outputs = pkgs.writeText "outputs" ''
    // Workspace 1
    workspace "${config.ws.w0}" {
      open-on-output "${config.displays.d1}"
    }
    workspace "${config.ws.w1}" {
      open-on-output "${config.displays.d1}"
    }
    workspace "${config.ws.w2}" {
      open-on-output "${config.displays.d1}"
    }
    workspace "${config.ws.w3}" {
      open-on-output "${config.displays.d1}"
    }
    workspace "${config.ws.w1a}" {
      open-on-output "${config.displays.d1}"
    }
    workspace "${config.ws.w2a}" {
      open-on-output "${config.displays.d1}"
    }
    workspace "${config.ws.w3a}" {
      open-on-output "${config.displays.d1}"
    }
    
    // Workspace 2
    workspace "${config.ws.w4}" {
      open-on-output "${config.displays.d2}"
    }
    workspace "${config.ws.w5}" {
      open-on-output "${config.displays.d2}"
    }
    workspace "${config.ws.w6}" {
      open-on-output "${config.displays.d2}"
    }
    workspace "${config.ws.w4a}" {
      open-on-output "${config.displays.d2}"
    }
    workspace "${config.ws.w5a}" {
      open-on-output "${config.displays.d2}"
    }
    
    // Workspace 3
    workspace "${config.ws.w7}" {
      open-on-output "${config.displays.d3}"
    }
    workspace "${config.ws.w8}" {
      open-on-output "${config.displays.d3}"
    }
    workspace "${config.ws.w9}" {
      open-on-output "${config.displays.d3}"
    }
    workspace "${config.ws.w7a}" {
      open-on-output "${config.displays.d3}"
    }
    workspace "${config.ws.w8a}" {
      open-on-output "${config.displays.d3}"
    }
    
    // Workspace 4
    workspace "${config.ws.w6a}" {
      open-on-output "${config.displays.d4}"
    }
    workspace "${config.ws.w9a}" {
      open-on-output "${config.displays.d4}"
    }
    
    // Monitors
    output "${config.displays.d1}" {
      mode "1920x1080@143.980"
      position x=3840 y=405
    }
    output "${config.displays.d2}" {
      mode "1920x1080@60"
      position x=1920 y=405
    }
    output "${config.displays.d3}" {
      mode "1680x1050@59.883"
      transform "90"
      position x=5760 y=0
    }
    output "${config.displays.d4}" {
      mode "1920x1080@60"
      position x=0 y=405
    }
  '';
}
