# Multi-Monitor Configuration (https://mangowm.github.io/docs/bar/multi-monitor-configuration)

mangobar can run a different bar on each output (monitor). Instead of a
single global configuration you may supply **profiles**, each optionally
bound to one or more Wayland output names (for example `DP-1`,
`HDMI-A-1` or `eDP-1`). Every profile is a full bar configuration, so
layout, height, module formats and actions can differ per monitor.

## Accepted configuration shapes [#accepted-configuration-shapes]

The top level of `config.jsonc` must be one of:

1. **A single object** — the classic configuration, used for every output
   (no profile selection needed):

   ```jsonc
   {
     "layer": "top",
     "height": 30,
     "modules-left": ["workspaces", "layout"],
     "modules-right": ["cpu", "memory", "clock#time"],
   }
   ```

2. **A root array of profile objects** — the recommended way to configure
   multiple monitors:

   ```jsonc
   [
     {
       "output": ["DP-1", "DP-2"],
       "height": 30,
       "modules-left": ["workspaces", "layout"],
       "modules-right": ["cpu", "memory", "clock#time"],
     },
     {
       // no "output" → fallback for any other monitor
       "height": 24,
       "modules-right": ["battery", "clock#time"],
     },
   ]
   ```

## Profile matching [#profile-matching]

Each profile may carry an `output` selector:

| `output` value                            | Meaning                                                        |
| ----------------------------------------- | -------------------------------------------------------------- |
| string, e.g. `"DP-1"`                     | Apply this profile to that output only                         |
| array of strings, e.g. `["DP-1", "DP-2"]` | Apply to each listed output                                    |
| omitted                                   | Fallback: apply to every output not matched by another profile |

Matching rules:

- Output names come from the compositor's xdg-output `name` event (usually
  the connector name).
- A profile without `output` is the **fallback**; at most one fallback is
  allowed.
- The same output name must not appear in more than one profile.
- If no profile matches an output **and** there is no fallback, mangobar
  simply shows no bar on that output.
- A single-object config that contains `"output"` behaves the same way: it
  applies to the listed outputs only, and other outputs get no bar. Omit
  `output` from a single object to keep the old "one bar everywhere"
  behavior.

## Examples [#examples]

### Same bar everywhere, different heights [#same-bar-everywhere-different-heights]

```jsonc
[
  {
    "output": "DP-1",
    "height": 32,
    "modules-left": ["workspaces", "layout"],
    "modules-right": ["clock#time"],
  },
  {
    // fallback: secondary/laptop displays
    "height": 24,
    "modules-left": ["workspaces"],
    "modules-right": ["battery", "clock#time"],
  },
]
```

### Minimal bar on one monitor, full bar elsewhere [#minimal-bar-on-one-monitor-full-bar-elsewhere]

```jsonc
[
  {
    "output": "HDMI-A-1",
    "height": 22,
    "modules-left": ["workspaces"],
    "modules-right": ["clock#time"],
  },
  {
    "height": 30,
    "modules-left": ["workspaces", "layout", "window"],
    "modules-center": [],
    "modules-right": ["network", "pulseaudio", "battery", "clock#time"],
  },
]
```

### Show a bar on selected outputs only [#show-a-bar-on-selected-outputs-only]

```jsonc
[
  {
    "output": ["DP-1", "DP-2"],
    "height": 30,
    "modules-right": ["cpu", "memory", "clock#time"],
  },
]
```

Outputs other than `DP-1` and `DP-2` get no bar here, because there is no
fallback profile.

## What is per-profile? [#what-is-per-profile]

Every profile is parsed independently and can set:

- `height`, `layer`, `buffer-scale`
- `modules-left`, `modules-center`, `modules-right`
- module sections and their formats, alternates, actions and scroll
  settings
- custom module commands, signals and intervals
- `workspaces` options such as `hide-empty`, `pinned` and `tag-names`

What stays shared:

- The CSS stylesheet (and the font) is shared by all profiles. When the top
  level is an array of profiles the `css` / `style` keys are rejected; put
  the stylesheet at the default location (`~/.config/mangobar/style.css`)
  or set `$MANGOBAR_CSS`. A single-object configuration may still set
  `css` / `style` inline.
- PulseAudio and backlight state is system-wide; profile-level `format`
  settings still apply per bar.

## Nix (Home Manager) [#nix-home-manager]

`services.mangobar.settings` accepts a single attribute set or a **list of
attribute sets**. A list is written as a JSON root array, one entry per
output profile:

```nix
services.mangobar = {
  enable = true;
  settings = [
    {
      output = [ "DP-1" ];
      height = 30;
      modules-right = [ "cpu" "memory" "clock#time" ];
    }
    {
      height = 24;
      modules-right = [ "battery" "clock#time" ];
    }
  ];
};
```

An empty list is rejected.

See [Configuration](/bar/configuration) for the full list of options available
inside each profile.