ironbar/docs/Configuration guide.md
Jake Stanger c9e66d4664
feat: common module options (show_if, on_click, tooltip)
The first three of many options that are common to all modules.

Resolves #36. Resolves partially #34.
2022-11-28 22:09:18 +00:00

6.8 KiB

By default, you get a single bar at the bottom of all your screens. To change that, you'll unsurprisingly need a config file.

This page details putting together the skeleton for your config to get you to a stage where you can start configuring modules. It may look long and overwhelming, but that is just because the bar supports a lot of scenarios!

If you want to see some ready-to-go config files check the examples folder and the example pages in the sidebar.

1. Create config file

The config file lives inside the ironbar directory in your XDG_CONFIG_DIR, which is usually ~/.config/ironbar.

Ironbar supports a range of configuration formats, so you can pick your favourite:

  • config.json
  • config.toml
  • config.yaml
  • config.corn (Experimental, includes variable support for re-using blocks. See here for info)

You can also override the default config path using the IRONBAR_CONFIG environment variable.

2. Pick your use-case

Ironbar gives you a few ways to configure the bar to suit your needs. This allows you to keep your config simple and relatively flat if your use-case is simple, and make it more complex if required.

a) I want the same bar across all monitors

Place the bar config inside the top-level object. This is automatically applied to each of your monitors.

JSON
{
  "position": "bottom",
  "height": 42,
  "start": [],
  "center": [],
  "end": []
}
TOML
position = "bottom"
height = 42
start = []
center = []
end = []
YAML
position: "bottom"
height: 42
start: [ ]
center: [ ]
end: [ ]
Corn
{
  position = "bottom"
  height = 42
  start = []
  center = []
  end = []
}

b) I want my config to differ across one or more monitors

Create a map/object called monitors inside the top-level object. Each of the map's keys should be an output name, and each value should be an object containing the bar config.

To find your output names, run wayland-info | grep wl_output -A1.

JSON
{
  "monitors": {
    "DP-1": {
      "start": []
    },
    "DP-2": {
      "position": "bottom",
      "height": 30,
      "start": []
    }
  }
}
TOML
[monitors]

[monitors.DP-1]
start = []

[monitors.DP-2]
position = "bottom"
height = 30
start = []
YAML
monitors:
  DP-1:
    start: [ ]
  DP-2:
    position: "bottom"
    height: 30
    start: [ ]
Corn
{
  monitors.DP-1.start = []
  monitors.DP-2 = {
    position = "bottom"
    height = 30
    start = []
  }
}

c) I want one or more monitors to have multiple bars

Create a map/object called monitors inside the top-level object. Each of the map's keys should be an output name. If you want the screen to have multiple bars, use an array of bar config objects. If you want the screen to have a single bar, use an object.

To find your output names, run wayland-info | grep wl_output -A1.

JSON
{
  "monitors": {
    "DP-1": [
      {
        "start": []
      },
      {
        "position": "top",
        "start": []
      }
    ],
    "DP-2": {
      "position": "bottom",
      "height": 30,
      "start": []
    }
  }
}
TOML
[monitors]

[[monitors.DP-1]]
start = []

[[monitors.DP-2]]
position = "top"
start = []

[monitors.DP-2]
position = "bottom"
height = 30
start = []
YAML
monitors:
  DP-1:
    - start: [ ]
    - position: "top"
      start: [ ]
  DP-2:
    position: "bottom"
    height: 30
    start: [ ]
Corn
{
  monitors.DP-1 = [
    { start = [] }
    { position = "top" start = [] }
  ]
  monitors.DP-2 = {
    position = "bottom"
    height = 30
    start = []
  }
}

3. Write your bar config(s)

Once you have the basic config structure set up, it's time to actually configure your bar(s).

Check here for an example config file for a fully configured bar in each format.

3.1 Top-level options

The following table lists each of the top-level bar config options:

Name Type Default Description
position top or bottom or left or right bottom The bar's position on screen.
anchor_to_edges boolean false Whether to anchor the bar to the edges of the screen. Setting to false centres the bar.
height integer 42 The bar's height in pixels.
start Module[] [] Array of left or top modules.
center Module[] [] Array of center modules.
end Module[] [] Array of right or bottom modules.

3.2 Module-level options

The following table lists each of the module-level options that are present on all modules. For details on available modules and each of their config options, check the sidebar.

For information on the Script type, see here.

Name Type Default Description
show_if Script [polling] null Polls the script to check its exit code. If exit code is zero, the module is shown. For other codes, it is hidden.
on_click Script [polling] null Runs the script when the module is clicked.
tooltip string null Shows this text on hover.