Profiles
Some modules support a profiles configuration option, which utilises the standardised configuration profiles system.
This allows a subset of the module’s configuration options to be overwritten depending on a defined value.
The value is related to the module’s state, and is normally a number of some sort.
Examples include volume and brightness percentage.
Profiles are defined as a map of the profile name to its state matcher (the special when key) and configuration.
The state matches on any value equal to or below the specified threshold.
Properties supported by the profiles system are marked as such on a module’s documentation page in the configuration section.
let { $volume = { // default - applies if no other profile is active icons.volume = ""
profiles = { // medium profile activates when volume <= 67% medium.when = 67 medium.icons.volume = ""
// low profile activates when volume <= 33% low.when = 33 low.icons.volume = ""
// other properties supported by the profile can also be updated low.icons.muted = "icons:volume-low-muted" } }} in { end = [ $volume ]}{ "end": [ { "icons": { "volume": "" }, "profiles": { "medium": { "when": 67, "icons": { "volume": "" } }, "low": { "when": 33, "icons": { "volume": "", "muted": "icons:volume-low-muted" } } } } ]}end: - icons: volume: profiles: medium: when: 67 icons: volume: low: when: 33 icons: volume: muted: icons:volume-low-muted[[end]][end.icons]volume = ""
[end.profiles.medium]when = 67
[end.profiles.medium.icons] volume = ""
[end.profiles.low]when = 33
[end.profiles.low.icons] volume = "" muted = "icons:volume-low-muted"Compound State
Some modules additionally support ‘compound’ state, allowing for the profile to match on more than one value. For example the battery module supports matching on both the charge percentage and whether the battery is currently charging.
More specific values for state matchers with the same value will take precedent.
let { $battery = { type = "battery"
format = "HIGH {percentage}%"
profiles = { low.when = { percent = 20 } low.format = "LOW {percentage}%"
// applies over `low` when charging. low-charging.when = { percent = 20 charging = true } low-charging.format = "LOW (CHARGING) {percentage}%"
// applies over `medium-charging` when NOT charging. medium.when = { percent = 50 charging = false } medium.format = "MEDIUM {percentage}%"
medium-charging.when = { percent = 50 } medium-charging.format = "MEDIUM (CHARGING) {percentage}%"
good.when = { percent = 75 charging = false } good.format = "GOOD {percentage}%"
good-charging.when = { percent = 75 charging = true } good-charging.format = "GOOD (CHARGING) {percentage}%"
empty.when = { percent = 1 charging = true } } }} in { end = [ $battery ]}{ "end": [ { "type": "battery", "format": "HIGH {percentage}%", "profiles": { "low": { "when": { "percent": 20 }, "format": "LOW {percentage}%" }, "low-charging": { "when": { "percent": 20, "charging": true }, "format": "LOW (CHARGING) {percentage}%" }, "medium": { "when": { "percent": 50, "charging": false }, "format": "MEDIUM {percentage}%" }, "medium-charging": { "when": { "percent": 50 }, "format": "MEDIUM (CHARGING) {percentage}%" }, "good": { "when": { "percent": 75, "charging": false }, "format": "GOOD {percentage}%" }, "good-charging": { "when": { "percent": 75, "charging": true }, "format": "GOOD (CHARGING) {percentage}%" }, "empty": { "when": { "percent": 1, "charging": true } } } } ]}end: - type: battery format: HIGH {percentage}% profiles: low: when: percent: 20 format: LOW {percentage}% low-charging: when: percent: 20 charging: true format: LOW (CHARGING) {percentage}% medium: when: percent: 50 charging: false format: MEDIUM {percentage}% medium-charging: when: percent: 50 format: MEDIUM (CHARGING) {percentage}% good: when: percent: 75 charging: false format: GOOD {percentage}% good-charging: when: percent: 75 charging: true format: GOOD (CHARGING) {percentage}% empty: when: percent: 1 charging: true[[end]]type = "battery"format = "HIGH {percentage}%"
[end.profiles.low]format = "LOW {percentage}%"
[end.profiles.low.when] percent = 20
[end.profiles.low-charging]format = "LOW (CHARGING) {percentage}%"
[end.profiles.low-charging.when] percent = 20 charging = true
[end.profiles.medium]format = "MEDIUM {percentage}%"
[end.profiles.medium.when] percent = 50 charging = false
[end.profiles.medium-charging]format = "MEDIUM (CHARGING) {percentage}%"
[end.profiles.medium-charging.when] percent = 50
[end.profiles.good]format = "GOOD {percentage}%"
[end.profiles.good.when] percent = 75 charging = false
[end.profiles.good-charging]format = "GOOD (CHARGING) {percentage}%"
[end.profiles.good-charging.when] percent = 75 charging = true
[end.profiles.empty.when]percent = 1charging = trueStyling
When a profile is active, a class name is appended to the module’s root widget in the form .profile-{name}.
This allows you to apply profile-specific styling as follows:
.battery.profile-medium { color: yellow;}
.battery.profile-low { color: red;}Shorthand syntax
If you wish to define a profile for styling only, and do not wish to override any configuration this is possible too.
While perfectly possible to write the matcher with no configuration as below:
let { $volume = { profiles.low.when = 33 profiles.medium.when = 67 }} in { end = [ $volume ]}{ "end": [ { "profiles": { "low": { "when": 33 }, "medium": { "when": 67 } } } ]}end: - profiles: low: when: 33 medium: when: 67[[end]][end.profiles.low]when = 33
[end.profiles.medium]when = 67…Ironbar also supports omitting the when key and attaching the state matcher directly.
let { $volume = { profiles.low = 33 profiles.medium = 67 }} in { end = [ $volume ]}{ "end": [ { "profiles": { "low": 33, "medium": 67 } } ]}end: - profiles: low: 33 medium: 67[[end]][end.profiles]low = 33medium = 67Default profiles
Modules that support the profiles system usually also provide a set of defaults. Naming a profile the same name as an existing default will override it.
If you seek more control, you can disable them with use_default_profiles = false:
let { $volume = { use_default_profiles = false profiles.my-low = 20 }} in { end = [ $volume ]}{ "end": [ { "use_default_profiles": false, "profiles": { "my-low": 20 } } ]}end: - use_default_profiles: false profiles: my-low: 20[[end]]use_default_profiles = false
[end.profiles] my-low = 20