# Custom (https://mangowm.github.io/docs/bar/modules/custom)

User-defined modules are declared as `custom/<name>` in a `modules-*` list
and defined under the same key in the config file.

```jsonc
"modules-left": ["workspaces", "custom/uptime"],

"custom/uptime": {
    "exec": "uptime -p | sed 's/^up //'",
    "interval": 60,
    "format": "󰅐 {}",
    "on-scroll-up": "brightnessctl s +5%",
    "on-scroll-down": "brightnessctl s 5%-"
}
```

## Options [#options]

| Option            | Type    | Default    | Description                                                             |
| ----------------- | ------- | ---------- | ----------------------------------------------------------------------- |
| `exec`            | string  | —          | Command whose stdout becomes the module text (trailing newline trimmed) |
| `interval`        | int (s) | `0`        | Refresh interval in seconds; `0`/omitted runs once at startup           |
| `signal`          | int     | `0`        | Realtime signal number `N` that re-runs the module (`SIGRTMIN+N`)       |
| `format`          | string  | raw output | Display format; `{}` is replaced with the exec output                   |
| `on-click`        | string  | —          | Command run on left click                                               |
| `on-click-middle` | string  | —          | Command run on middle click                                             |
| `on-click-right`  | string  | —          | Command run on right click                                              |
| `on-scroll-up`    | string  | —          | Command run on scroll up                                                |
| `on-scroll-down`  | string  | —          | Command run on scroll down                                              |

## Signals [#signals]

With `signal` set and no `interval`, the script runs once at startup and then
only when the signal arrives:

```jsonc
"custom/pacman": {
    "exec": "checkupdates | wc -l",
    "signal": 8,
    "format": "󰮯 {}",
    "on-click": "sudo pacman -Syu && pkill -RTMIN+8 mangobar"
}
```

With both `signal` and `interval`, the module also refreshes on the interval.

## Styling [#styling]

Custom modules are styled with `#custom-<name>` selectors:

```css
#custom-power {
  margin: 0px 5px;
  background: linear-gradient(to top, #83a598, mix(#83a598, #fbf1c7, 0.3));
  color: #1b1a1a;
}
```

> **Note:** a custom module is only configured if it is placed in a
> `modules-*` list.