Skip to content

Bar Placement

Bakkeby edited this page Feb 27, 2024 · 6 revisions

The bars setting in config.h defines the bars that are present on which monitors as well as their size and position.

static const BarDef bars[] = {
	/* monitor idx  vert   x     y      w     h     name  */
	{  0,      0,   0,    "0%    0%     100% -1h ", "Primary top" },
	{  0,      1,   0,    "0%    100%   100% -1h ", "Primary bottom" },
	{  1,      0,   0,    "0%    0%     100% -1h ", "Secondary top" },
	{  1,      1,   0,    "0%    100%   100% -1h ", "Secondary bottom" },
	{  2,      0,   0,    "0%    0%     100% -1h ", "Tertiary top" },
	{  2,      1,   0,    "0%    100%   100% -1h ", "Tertiary bottom" },
};

The default configuration, as seen above, defines a top bar and a bottom bar for each of the first three monitors and each bar takes up the full width of the monitor.

If you happen to have more monitors than that then the fourth one will be without a bar unless one is added to the bars list.

Options Description
monitor The monitor (index) the bar should be created on, e.g. 0 (primary), 1 (secondary), 2 (tertiary)
idx The bar index, used in relation to bar rules (can be reused across monitors)
vert Whether the bar is horizontal (0) or vertical (1), not all bar modules will have support for being displayed in a vertical bar
barpos String containing size and positional data, outlined separately below
name Does nothing, intended as a visual clue and for logging or debugging

If anything is unclear with regards to the monitor index (or number) used here then refer to the Monitor topic.

The bar index (idx) is arbitrary and can be unique on a per monitor basis if preferred. More importantly the bar index can be re-used across monitors allowing for the same or similar bars to be added across monitors. One could also think of the bar index as form of type.

This comes into play when we look at the Bar Rules. As an example instead of having to define that the primary bar on each monitor is to show common modules such as workspace icons and window titles one can instead say that all bars that have an index of 0 should have these modules.

The vert option determines whether the bar is horizontal or vertical. Yes you can actually have a vertical bar, but bar modules that properly support that is in limited supply so manage your expectations.

The bar positioning (barpos) is a string that consists of four values, x, y, w and h which, similarly to how floatpos strings are composed, can have different meaning depending on the characters used.

This is perhaps best explained with some example values.

x

Value Description
0% Left aligned (default)
100% Right aligned
50% Bar is centered on the screen
0x Exact position relative to the monitor
-1x Value < 0 means use default

Exact positions are relative to the monitor which means that a value of 20 means twenty pixels from the start of the monitor edge regardless of which monitor it is.

As such absolute positioning (as in cross-monitor) is not supported.

y

Value Description
0% Top bar (default)
100% Bottom bar
0y Exact position relative to the monitor
-1y Value < 0 means use default

The y value can be used to have the primary bar as a bottom bar instead of a top bar which is the default.

It is also possible to have one bar directly beneath the other if that is of interest.

w

Value Description
100% Bar takes up the full width of the screen (default)
20% Small bar taking a fifth of the width of the screen
500w The bar is 500 pixels wide (including border)
-1w Value <= 0 means use default

Changing the width here is intended for when vertical bars is used or when multiple smaller horizontal bars are used. For example one can have three smaller bars; one in the middle of the screen and the other two on the left and right hand sides.

h

Value Description
100% Bar takes up the full height of the screen
20% Small bar taking a fifth of the height of screen
30h The bar is 30 pixels high (including border)
-1h Value <= 0 means use the default (deduced by font size)

Note that if the bar height is set here then this will override:

  • the default height of the bar which is derived from the font height and
  • the vertpadbar configuration which adjusts that and
  • the bar_height configuration which sets an absolute height

The height here is primarily intended for when vertical bars are used.


While absolute values can be used the general recommendation is to use percentages instead as these are relative to the space available on the monitor and are therefore more portable.


Note that vertical and horizontal side padding are controlled by the BarPadding functionality and as such you do not need to take that into account here when it comes to positioning. Also see the vertpad and sidepad settings in config.h.


Back to Bar.

Clone this wiki locally