-
Notifications
You must be signed in to change notification settings - Fork 23
Bar Rules
The bar rules control which modules are present on a bar and their position on the bar.
Refer to the Bar Placement page for details on how to create additional bars.
static const BarRule barrules[] = {
/* monitor bar scheme lpad rpad value alignment sizefunc drawfunc clickfunc hoverfunc name */
{ -1, 0, 0, 0, 5, 0, BAR_ALIGN_LEFT, size_workspaces, draw_workspaces, click_workspaces, hover_workspaces, "workspaces" },
{ 'A', 0, 0, 5, 5, 0, BAR_ALIGN_RIGHT, size_systray, draw_systray, click_systray, NULL, "systray" },
{ -1, 0, 0, 0, 0, 0, BAR_ALIGN_LEFT, size_ltsymbol, draw_ltsymbol, click_ltsymbol, NULL, "layout" },
{ 0, 0, 0, 10, 0, 0, BAR_ALIGN_RIGHT, size_status, draw_status, click_status, NULL, "status0" },
{ 0, 0, 0, 10, 0, 1, BAR_ALIGN_RIGHT, size_status, draw_status, click_status, NULL, "status1" },
{ 0, 0, 0, 10, 0, 2, BAR_ALIGN_RIGHT, size_status, draw_status, click_status, NULL, "status2" },
{ 0, 0, 0, 10, 0, 3, BAR_ALIGN_RIGHT, size_status, draw_status, click_status, NULL, "status3" },
{ 0, 0, 0, 10, 0, 4, BAR_ALIGN_RIGHT, size_status, draw_status, click_status, NULL, "status4" },
{ 0, 0, 0, 10, 0, 5, BAR_ALIGN_RIGHT, size_status, draw_status, click_status, NULL, "status5" },
{ 0, 0, 0, 10, 0, 6, BAR_ALIGN_RIGHT, size_status, draw_status, click_status, NULL, "status6" },
{ 0, 0, 0, 10, 0, 7, BAR_ALIGN_RIGHT, size_status, draw_status, click_status, NULL, "status7" },
{ 0, 0, 0, 10, 0, 8, BAR_ALIGN_RIGHT, size_status, draw_status, click_status, NULL, "status8" },
{ -1, 0, 0, 5, 0, 0, BAR_ALIGN_NONE, size_flexwintitle, draw_flexwintitle, click_flexwintitle, NULL, "flexwintitle" },
{ 'A', 1, 0, 10, 10, 9, BAR_ALIGN_RIGHT, size_status, draw_status, click_status, NULL, "status9" },
{ -1, 1, 0, 0, 0, 0, BAR_ALIGN_RIGHT_RIGHT, size_wintitle_hidden, draw_wintitle_hidden, click_wintitle_hidden, NULL, "wintitle_hidden" },
{ -1, 1, 0, 0, 0, 0, BAR_ALIGN_LEFT, size_wintitle_floating, draw_wintitle_floating, click_wintitle_floating, NULL, "wintitle_floating" },
};
Options | Description |
---|---|
monitor | The monitor (index) the bar should be created on, e.g. 0 (primary), 1 (secondary), 2 (tertiary) |
bar (index) | The bar index |
scheme | Specifies the default colour scheme for the module (used unless the module itself controls colours) |
lpad | Adds artificial spacing (in pixels) on the left hand side of the module |
rpad | Adds artificial spacing (in pixels) on the right hand side of the module |
value | An arbitrary value where the interpretation is module specific |
alignment | Determines where on the bar the module will be placed |
sizefunc | Function providing the width (or height) of the module |
drawfunc | Function providing the drawing of the module |
clickfunc | Function providing the button click handling of the module |
hoverfunc | Function providing the mouse hover handling of the module |
name | Does nothing, intended as a visual clue and for logging or debugging |
This is a filter that determines whether the rule applies based on the monitor index (or number).
Special values that can be used here are:
-
-1
- the rule applies to all monitors -
'A'
- the rule applies to active monitor (as in currently focused monitor)
If anything is unclear with regards to the monitor index then refer to the Monitor topic.
This is a filter that determines whether the rule applies based on the bar index.
The bar index is defined in the bars
setting in config.h and one can think
of it as a way to group bars of a certain type together.
Refer to the Bar Placement page for more details on that.
Defines the default scheme for the bar module.
When it comes to the colour scheme
the default bar rules have the value of 0 which is the default
colour scheme (SchemeNorm
). Refer to the colors
settings in config.h
for more information.
Note that the colours can in most cases also be controlled using status2d markup.
The lpad
and rpad
options add artificial space on the left and right hand side of the module.
This can be used to add some space to avoid modules being too close to each other.
The interpretation of the value
field is module specific and for now this is only used by the
status module.
A module's placement on the bar is relative to other modules that comes before it and as such they are do not have absolute coordinates where they are to be placed.
Instead they have an alignment such that they float to the left, right or center.
If a module is aligned to the center of the bar then that breaks the remaining space up into two; the left hand side of the center and the right hand side of the center.
Here is a breakdown of the alignment options:
Alignment | Description |
---|---|
BAR_ALIGN_LEFT | Positions the module on the left side of the bar |
BAR_ALIGN_RIGHT | Positions the module on the right side of the bar |
BAR_ALIGN_CENTER | Centers the module in the remaining space |
BAR_ALIGN_LEFT_LEFT | Following a center split, place the module on the left hand side on the left of the center module |
BAR_ALIGN_LEFT_RIGHT | Following a center split, place the module on the right hand side on the left of the center module |
BAR_ALIGN_LEFT_CENTER | Following a center split, place the module in the middle of the remaining space on the left of the center module |
BAR_ALIGN_RIGHT_LEFT | Following a center split, place the module on the left hand side on the right of the center module |
BAR_ALIGN_RIGHT_RIGHT | Following a center split, place the module on the right hand side on the right of the center module |
BAR_ALIGN_RIGHT_CENTER | Following a center split, place the module in the middle of the remaining space on the right of the center module |
BAR_ALIGN_NONE | No particular alignment |
If a module is to be placed in the dead center of the bar then it needs to be the first rule in the
list and use the BAR_ALIGN_CENTER
alignment. Otherwise the module is centered in the remaining
space.
The BAR_ALIGN_NONE
alignment is primarily a visual clue to the user and in practice it will align
the module to the left. This is typically used for modules that take up the remaining space, e.g.
modules that draw window titles.
These are individual functions that:
- returns the width of the module (as in how much space does it require) and
- draws the content of the module and
- handles module specific interpretation of mouse button presses and
- handles module specific interpretation of mouse hover events
From an end user perspective it may potentially have been more intuitive to just say "use the workspaces module" rather than having to refer to individual functions here.
The idea is that you can in principle swap out only a part of the module, e.g. providing your own click function that does something different to the default logic.
You only need to make changes to these if you are adding custom modules.
Refer to the Bar Modules page which goes more into details regarding this.
This is has no effect and is just meant as a visual clue to the user.
It may be used as part of debug logging.
Back to Bar.
Concepts | Configuration | Features | Flags | Functionality | Functions