How_to_add_new_colour_schemes - bakkeby/dusk GitHub Wiki

If you find yourself wanting a custom colour for one of your statuses, or want to play around with different colours per workspace icon, then you may want to consider adding some new colour schemes for this purpose.

Adding new colour schemes to dusk is fairly straightforward.

Idea

Let's go wild and have a different colour for each of the nine workspaces. This would be similar to the look of the colourful tags or rainbow tags patches for dwm.

Adding new colour schemes

In dusk.c search for "SchemeNorm" to find the list of available colour schemes in play.

enum {
	SchemeNorm,
	SchemeSel,
	SchemeTitleNorm,
	SchemeTitleSel,
	SchemeWsNorm,
	SchemeWsVisible,
	SchemeWsSel,
	SchemeWsOcc,
	SchemeScratchSel,
	SchemeScratchNorm,
	SchemeHidSel,
	SchemeHidNorm,
	SchemeUrg,
	SchemeMarked,
	...
	SchemeFlexSelFloat,
	SchemeLast,
}; /* color schemes */

Now, we will want to add our new colour schemes to this list. We can add them right before the SchemeLast entry which holds the count of colour schemes - and we want to make sure that this is indeed the last item in the list.

What colour schemes to add will depend on how you want the colours to behave.

For example you may want to:

  • only have a mix of default colours, but stick to the usual colours when the workspace is occupied by clients and/or selected or
  • stick with the default colours, but have a different colour when the workspace is occupied by clients or
  • only have a different colour when the workspace is selected or
  • change all the colours

If you haven't already done so then you may want to have a read through the schemes used by the Workspace Module.

If you want to change all the colours then that will be 4 schemes x 9 workspaces which gives a total of 36 new colour schemes. For brevity this guide will only demonstrate adding new default colours for the workspace icons. Adding colour schemes for visible, selected and occupied workspaces will be left as an exercise for the reader.

The default colour scheme that is used for workspace icons is SchemeWsNorm. To make that unique per workspace we will just append a number to it and add it to the list.

We then end up with:

enum {
	...
	SchemeFlexSelFloat,
	SchemeWsNorm1,
	SchemeWsNorm2,
	SchemeWsNorm3,
	SchemeWsNorm4,
	SchemeWsNorm5,
	SchemeWsNorm6,
	SchemeWsNorm7,
	SchemeWsNorm8,
	SchemeWsNorm9,
	SchemeLast,
}; /* color schemes */

Now we will need to add some default colours for these new colour schemes.

Adding default colours

We need to add the new workspaces to the colors array in the configuration file.

E.g.

static char *colors[SchemeLast][4] = {
	/*                       fg         bg         border     resource prefix */
	...
	[SchemeWsSel]        = { "#D9CFC5", "#82363A", "#000000" },
	[SchemeWsOcc]        = { "#D9CFC5", "#492B2D", "#000000" },
	[SchemeWsNorm1]      = { "#BE89AE", "#D71111", "#000000", "wsnorm1" },
	[SchemeWsNorm2]      = { "#BE89AE", "#C0C607", "#000000", "wsnorm2" },
	[SchemeWsNorm3]      = { "#BE89AE", "#4C6EF2", "#000000", "wsnorm3" },
	[SchemeWsNorm4]      = { "#BE89AE", "#5C1515", "#000000", "wsnorm4" },
	[SchemeWsNorm5]      = { "#BE89AE", "#D96625", "#000000", "wsnorm5" },
	[SchemeWsNorm6]      = { "#BE89AE", "#C61A95", "#000000", "wsnorm6" },
	[SchemeWsNorm7]      = { "#BE89AE", "#A41DD8", "#000000", "wsnorm7" },
	[SchemeWsNorm8]      = { "#BE89AE", "#52E23D", "#000000", "wsnorm8" },
	[SchemeWsNorm9]      = { "#BE89AE", "#4ADBD2", "#000000", "wsnorm9" },
};

The resource prefix of "wsnorm1", "wsnorm2", etc. are there in case you want to override these colours using Xresources down the line.

These can then be overridden with the resource strings of dusk.wsnorm1.fg.color, dusk.wsnorm1.bg.color, dusk.wsnorm1.border.color, dusk.wsnorm2.fg.color, etc.

The resource prefixes can alternatively be added to the default_resource_prefixes array in dusk.c, directly below the colour scheme enum.

If you omit the resource prefixes then the colours will simply not be loaded via Xresources.

Refer to the Xresources functionality for more details.

Adding the alpha values

If you want your new colour scheme to have a transparency level different to the defaults then you can add custom transparency settings via Xresources.

Example resource strings to set opacity levels.

dusk.wsnorm1.bg.alpha: 26
dusk.wsnorm2.bg.alpha: 51
dusk.wsnorm3.bg.alpha: 77
dusk.wsnorm4.bg.alpha: 102
dusk.wsnorm5.bg.alpha: 128
dusk.wsnorm6.bg.alpha: 153
dusk.wsnorm7.bg.alpha: 179
dusk.wsnorm8.bg.alpha: 204
dusk.wsnorm9.bg.alpha: 230

The value range is 0 to 255. The values above are 10% for "wsnorm1", 20% for "wsnorm2" and so on up to 90% opacity for "wsnorm9".

An alternative could be to use RGBA values when setting the background colour, e.g.

dusk.wsnorm9.bg.color: #FF6060E6

Using the new colour schemes

In the workspace rules now replace the default scheme of "SchemeWsNorm" with our new ones.

static const WorkspaceRule wsrules[] = {
	/*     ------------------------------- schemes -------------------------------
	       default,          visible,          selected,         occupied,         */
	{  ... SchemeWsNorm1,    SchemeWsVisible,  SchemeWsSel,      SchemeWsOcc,      ...
	{  ... SchemeWsNorm2,    SchemeWsVisible,  SchemeWsSel,      SchemeWsOcc,      ...
	{  ... SchemeWsNorm3,    SchemeWsVisible,  SchemeWsSel,      SchemeWsOcc,      ...
	{  ... SchemeWsNorm4,    SchemeWsVisible,  SchemeWsSel,      SchemeWsOcc,      ...
	{  ... SchemeWsNorm5,    SchemeWsVisible,  SchemeWsSel,      SchemeWsOcc,      ...
	{  ... SchemeWsNorm6,    SchemeWsVisible,  SchemeWsSel,      SchemeWsOcc,      ...
	{  ... SchemeWsNorm7,    SchemeWsVisible,  SchemeWsSel,      SchemeWsOcc,      ...
	{  ... SchemeWsNorm8,    SchemeWsVisible,  SchemeWsSel,      SchemeWsOcc,      ...
	{  ... SchemeWsNorm9,    SchemeWsVisible,  SchemeWsSel,      SchemeWsOcc,      ...
};

If a new colour scheme were to be used for a status as an example then you would use this in the scheme column of the barrules config.

Result

Having done all that we compile and we get this disturbing looking workspace extravaganza:

workspace_colours.jpg


Back to Guides.

⚠️ **GitHub.com Fallback** ⚠️