Skip to content

Commit

Permalink
feature: support simple colour settings for text fields too (#1511)
Browse files Browse the repository at this point in the history
* feature: support simple colour settings for text fields too

* also add 'color' back to some options

* tests
  • Loading branch information
ClementTsang authored Jul 30, 2024
1 parent 95905d7 commit f091ebd
Show file tree
Hide file tree
Showing 15 changed files with 445 additions and 192 deletions.
60 changes: 34 additions & 26 deletions docs/content/configuration/config-file/styling.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ field = { color = "black", bg_color = "blue", bold = false }

All fields are optional; by default if `bg_color` is not set then there will be no background color.

If you _just_ want to style text by setting the foreground colour, for brevity, then you can also just set the field
to be the colour itself. For example:

```toml
[styles.widgets]
selected_text = "#fff"
```

### Configuration

#### CPU
Expand All @@ -99,34 +107,34 @@ These can be set under `[styles.cpu]`:

These can be set under `[styles.memory]`:

| Config field | Details | Examples |
| ------------ | ------------------------------------------------------------------------------ | --------------------------------- |
| `ram` | The colour of the RAM label and graph line | `ram = "Red"` |
| `cache` | The colour of the cache label and graph line. Does not do anything on Windows. | `cache = "#ffffff"` |
| `swap` | The colour of the swap label and graph line | `swap = "255, 0, 255"` |
| `arc` | The colour of the ARC label and graph line | `arc = "Blue"` |
| `gpus` | Colour of each GPU's memory label and graph line. Read in order. | `gpus = ["Red", "Blue", "Green"]` |
| Config field | Details | Examples |
| ------------- | ------------------------------------------------------------------------------ | --------------------------------------- |
| `ram_color` | The colour of the RAM label and graph line | `ram_color = "Red"` |
| `cache_color` | The colour of the cache label and graph line. Does not do anything on Windows. | `cache_color = "#ffffff"` |
| `swap_color` | The colour of the swap label and graph line | `swap_color = "255, 0, 255"` |
| `arc_color` | The colour of the ARC label and graph line | `arc_color = "Blue"` |
| `gpu_colors` | Colour of each GPU's memory label and graph line. Read in order. | `gpu_colors = ["Red", "Blue", "Green"]` |

#### Network

These can be set under `[styles.network]`:

| Config field | Details | Examples |
| ------------ | --------------------------------------------------------- | ---------------------- |
| `rx` | The colour of the RX (download) label and graph line | `rx = "Red"` |
| `tx` | The colour of the TX (upload) label and graph line. | `tx = "#ffffff"` |
| `rx_total` | The colour of the total RX (download) label in basic mode | `rx_total = "0, 0, 0"` |
| `tx_total` | The colour of the total TX (upload) label in basic mode | `tx_total = "#000"` |
| Config field | Details | Examples |
| ---------------- | --------------------------------------------------------- | ---------------------------- |
| `rx_color` | The colour of the RX (download) label and graph line | `rx_color = "Red"` |
| `tx_color` | The colour of the TX (upload) label and graph line | `tx_color = "#ffffff"` |
| `rx_total_color` | The colour of the total RX (download) label in basic mode | `rx_total_color = "0, 0, 0"` |
| `tx_total_color` | The colour of the total TX (upload) label in basic mode | `tx_total_color = "#000"` |

#### Battery

These can be set under `[styles.battery]`:

| Config field | Details | Examples |
| ---------------- | ------------------------------------------------------------------------ | ---------------------------- |
| `high_battery` | The colour of the battery widget bar when the battery is over 50% | `high_battery = "Red"` |
| `medium_battery` | The colour of the battery widget bar when the battery between 10% to 50% | `medium_battery = "#ffffff"` |
| `low_battery` | The colour of the battery widget bar when the battery is under 10% | `low_battery = "0, 0, 0"` |
| Config field | Details | Examples |
| ---------------------- | ------------------------------------------------------------------------ | ---------------------------------- |
| `high_battery_color` | The colour of the battery widget bar when the battery is over 50% | `high_battery_color = "Red"` |
| `medium_battery_color` | The colour of the battery widget bar when the battery between 10% to 50% | `medium_battery_color = "#ffffff"` |
| `low_battery_color` | The colour of the battery widget bar when the battery is under 10% | `low_battery_color = "0, 0, 0"` |

#### Tables

Expand All @@ -149,11 +157,11 @@ These can be set under `[styles.graphs]`:

These can be set under `[styles.widgets]`:

| Config field | Details | Examples |
| ----------------- | ------------------------------------------------------------ | --------------------------------------------------------------------- |
| `border` | The colour of the widgets' borders | `border = "white"` |
| `selected_border` | The colour of a widget's borders when the widget is selected | `selected_border = "white"` |
| `widget_title` | Text styling for a widget's title | `widget_title = { color = "black", bg_color = "blue", bold = true }` |
| `text` | Text styling for text in general | `text = { color = "black", bg_color = "blue", bold = true }` |
| `selected_text` | Text styling for text when representing something selected | `selected_text = { color = "black", bg_color = "blue", bold = true }` |
| `disabled_text` | Text styling for text when representing something disabled | `disabled_text = { color = "black", bg_color = "blue", bold = true }` |
| Config field | Details | Examples |
| ----------------------- | ------------------------------------------------------------ | --------------------------------------------------------------------- |
| `border_color` | The colour of the widgets' borders | `border_color = "white"` |
| `selected_border_color` | The colour of a widget's borders when the widget is selected | `selected_border_color = "white"` |
| `widget_title` | Text styling for a widget's title | `widget_title = { color = "black", bg_color = "blue", bold = true }` |
| `text` | Text styling for text in general | `text = { color = "black", bg_color = "blue", bold = true }` |
| `selected_text` | Text styling for text when representing something that is selected | `selected_text = { color = "black", bg_color = "blue", bold = true }` |
| `disabled_text` | Text styling for text when representing something that is disabled | `disabled_text = { color = "black", bg_color = "blue", bold = true }` |
28 changes: 14 additions & 14 deletions sample_configs/default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,22 @@
#cpu_core_colors = ["light magenta", "light yellow", "light cyan", "light green", "light blue", "cyan", "green", "blue"]

#[styles.memory]
#ram = "light magenta"
#cache = "light red"
#swap = "light yellow"
#arc = "light cyan"
#gpus = ["light blue", "light red", "cyan", "green", "blue", "red"]
#ram_color = "light magenta"
#cache_color = "light red"
#swap_color = "light yellow"
#arc_color = "light cyan"
#gpu_colors = ["light blue", "light red", "cyan", "green", "blue", "red"]

#[styles.network]
#rx = "light magenta"
#tx = "light yellow"
#rx_total = "light cyan"
#tx_total = "light green"
#rx_color = "light magenta"
#tx_color = "light yellow"
#rx_total_color = "light cyan"
#tx_total_color = "light green"

#[styles.battery]
#high_battery = "green"
#medium_battery = "yellow"
#low_battery = "red"
#high_battery_color = "green"
#medium_battery_color = "yellow"
#low_battery_color = "red"

#[styles.tables]
#headers = {color = "light blue"}
Expand All @@ -172,8 +172,8 @@
#legend_text = {color = "gray"}

#[styles.widgets]
#border = "gray"
#selected_border = "light blue"
#border_color = "gray"
#selected_border_color = "light blue"
#widget_title = {color = "gray"}
#text = {color = "gray"}
#selected_text = {color = "black", bg_color = "light blue"}
Expand Down
Loading

0 comments on commit f091ebd

Please sign in to comment.