{ config, ... }:
{
  # Monitors
  wayland.windowManager.sway.config = {
    workspaceOutputAssign = let
      workspaces1 = [
        "0:${config.ws.w0}"
        "1:${config.ws.w1}"
        "2:${config.ws.w2}"
        "3:${config.ws.w3}"
        "11:${config.ws.w1a}"
        "22:${config.ws.w2a}"
        "33:${config.ws.w3a}"
      ];
      workspaces2 = [
        "4:${config.ws.w4}"
        "5:${config.ws.w5}"
        "6:${config.ws.w6}"
        "44:${config.ws.w4a}"
        "55:${config.ws.w5a}"
      ];
      workspaces3 = [
        "7:${config.ws.w7}"
        "8:${config.ws.w8}"
        "9:${config.ws.w9}"
        "77:${config.ws.w7a}"
        "88:${config.ws.w8a}"
      ];
      workspaces4 = [
        "66:${config.ws.w6a}"
        "99:${config.ws.w9a}"
      ];
      assign = output: workspaces:
        map (workspace: {
          inherit workspace;
          inherit output;
        })
        workspaces;
    in
      (assign "${config.displays.d1}" workspaces1) ++
      (assign "${config.displays.d2}" workspaces2) ++
      (assign "${config.displays.d3}" workspaces3) ++
      (assign "${config.displays.d4}" workspaces4);

    output = {
      ${config.displays.d1} = {
        pos = "3840 405";
        mode = "1920x1080@143.980Hz";
        max_render_time = "3";
	allow_tearing = "yes";
      };
      ${config.displays.d2} = {
        pos = "1920 405";
        mode = "1920x1080@60Hz";
        max_render_time = "3";
      };
      ${config.displays.d3} = {
        pos = "5760 0";
        mode = "1680x1050@59.883Hz";
        transform = "270";
        max_render_time = "3";
      };
      ${config.displays.d4} = {
        pos = "0 405";
        mode = "1920x1080@60Hz";
        max_render_time = "3";
      };
    };
  };
}
