Skip to content

How to write a theme

tobi-wan-kenobi edited this page Nov 6, 2016 · 11 revisions

Writing a new theme is relatively straight-forward:

  • Place a new YAML-formatted file into <i3bumblebee folder>/bumblebee/themes/ (the name of the file is the name of the theme)
  • Fill the YAML file with your requirements

Alternatively, you can also use a JSON file with the same format. If both files are present, the YAML format will be preferred.

Depending on the complexity of the theme, the second part can be either easy or slightly tricky :)

The theme configuration is considered in the following order:

  • If there is a configuration for the specific module and its state, use it
  • Otherwise, fall back to the module-specific configuration
  • If no module-specific configuration exists, fall back to the "defaults" configuration
  • If no configuration if found in "defaults", fall back to the defaults set in the i3 configuration

The following attributes are currently supported:

  • prefix is data that is printed before the data element (e.g. an icon if you use a font that supports it)
  • suffix is data that is printed after the data element
  • fg is the font color
  • bg is the background color
  • fg-critical is the font color for elements that are marked as being in "critical" state
  • bg-critical is the background color for elements that are marked as being in "critical" state
  • fg-warning is the font color for elements that are marked as being in "warning" state
  • bg-warning is the background color for elements that are marked as being in "warning" state
  • cycle is a list that can be used instead of plain fg and bg colors to make the modules cycle through a set of colors (e.g. to alternate between two sets). See the solarized theme for an example of this
  • default-separators can be used in the defaults section to either enable (True) or disable (False) the default i3bar separators
  • separator can be used in the defaults section to specify a custom separator, if the default separator is disabled

Furthermore, each module can have separate configurations and separate states. The states are determined by the modules themselves, and in the theme, it is possible to specify all of the items above also on a per-status level.

For a full example of a theme that uses all capabilities, please have a look at solarized-powerline.json.

A very simple example could look like this (it's actually the current default.yaml:

defaults: 
 prefix: " "
 suffix: " "
 urgent: true
 fg: "#aabbcc"
date: 
 prefix: " "
time: 
 prefix: " "
memory: 
 prefix: " ram "
cpu: 
 prefix: " cpu "
disk: 
 prefix: " hdd "
dnf: 
 prefix: " dnf "
pasink: 
 states: 
  muted: 
   prefix: " audio(mute) "
  unmuted: 
   prefix: " audio "
pasource: 
 states: 
  muted: 
   prefix: " mic(mute) "
  unmuted: 
   prefix: " mic "
nic: 
 states: 
  "wireless-up": 
   prefix: " wifi "
  "wireless-down": 
   prefix: " wifi "
  "wired-up": 
   prefix: " lan "
  "wired-down": 
   prefix: " lan "
  "tunnel-up": 
   prefix: " tun "
  "tunnel-down": 
   prefix: " tun "
battery: 
 states: 
  charged: 
   suffix: " full "
  charging: 
   suffix: " chr "
  discharging-10: 
   prefix: " ! "
   suffix: " dis "
  discharging-25: 
   suffix: " dis "
  discharging-50: 
   suffix: " dis "
  discharging-80: 
   suffix: " dis "
  discharging-100: 
   suffix: " dis "

The same file in JSON notation looks like this:

{
	"defaults": {
		"prefix": " ",
		"suffix" : " ",
		"urgent": true,
		"fg": "#aabbcc"
	},
	"date": {
		"prefix": " "
	},
	"time": {
		"prefix": " "
	},
	"memory": {
		"prefix": " ram "
	},
	"cpu": {
		"prefix": " cpu "
	},
	"disk": {
		"prefix": " hdd "
	},
	"dnf": {
		"prefix": " dnf "
	},
	"pasink": {
		"states": {
			"muted": {
				"prefix": " audio(mute) "
			},
			"unmuted": {
				"prefix": " audio "
			}
		}
	},
	"pasource": {
		"states": {
			"muted": {
				"prefix": " mic(mute) "
			},
			"unmuted": {
				"prefix": " mic "
			}
		}
	},
	"nic": {
		"states": {
			"wireless-up": {
				"prefix": " wifi "
			},
			"wireless-down": {
				"prefix": " wifi "
			},
			"wired-up": {
				"prefix": " lan "
			},
			"wired-down": {
				"prefix": " lan "
			},
			"tunnel-up": {
				"prefix": " tun "
			},
			"tunnel-down": {
				"prefix": " tun "
			}
		}
	},
	"battery": {
		"states": {
			"charged": {
				"suffix": " full "
			},
			"charging": {
				"suffix": " chr "
			},
			"discharging-10": {
				"prefix": " ! ",
				"suffix": " dis "
			},
			"discharging-25": {
				"suffix": " dis "
			},
			"discharging-50": {
				"suffix": " dis "
			},
			"discharging-80": {
				"suffix": " dis "
			},
			"discharging-100": {
				"suffix": " dis "
			}
		}
	}
}

Clone this wiki locally