[PR #1224] [MERGED] Fix(bar): simplify bar config #1264

Closed
opened 2026-01-05 14:54:41 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/LGUG2Z/komorebi/pull/1224
Author: @alex-ds13
Created: 1/10/2025
Status: Merged
Merged: 1/23/2025
Merged by: @LGUG2Z

Base: masterHead: fix(bar)/simplify-bar-config


📝 Commits (2)

  • 0093d82 fix(bar): simplify config for bar
  • 45ffb89 fix(bar): pass reconnect event to bar

📊 Changes

7 files changed (+707 additions, -230 deletions)

View changed files

📝 docs/komorebi.bar.example.json (+1 -9)
📝 komorebi-bar/src/bar.rs (+217 -54)
📝 komorebi-bar/src/config.rs (+216 -3)
📝 komorebi-bar/src/komorebi.rs (+80 -97)
📝 komorebi-bar/src/main.rs (+34 -34)
📝 komorebi-bar/src/render.rs (+7 -1)
📝 schema.bar.json (+152 -32)

📄 Description

Old users will still be able to use the old options, however it should be discouraged or even deprecated to use the following configs:

Configs to remove:

  • work_area_offset inside monitor
  • position
  • frame

If you remove all the options above the bar will still show up with a default height of 50 and a default padding of 10 all around.

If you need to customize the bar height, padding or margin you should use these new options:

New Configs:

  • height: the height you want for the bar itself
  • margin: this option allows you to set a margin around the bar (default: 0). You can either set it like this:
"margin": 10 // It will use a spacing of 10 on all sides of the bar

or like this:

"margin": {
  "vertical": 10 // It will use a spacing of 10 above and below the bar
}

or like this (vertical and horizontal are optional you can set only one axis and the other will be left at default value):

"margin": {
  "vertical": [10, 0], // It will use a spacing of 10 above the bar but no spacing below
  "horizontal": 10,  // It will use a spacing of 10 on the left and right sides of the bar
}

or even like this to specify each side individually:

"margin": {
  "top": 10,
  "bottom": 0,
  "left": 0,
  "right": 0
}
  • padding: this option allows you to set a padding inside the bar (default: 10 on all sides). The higher the padding the smaller the widgets will be, if the vertical padding is set at 0 the widgets will try to fill the entire height of the bar. This option can be set just like the margin above.

Changed Configs:

  • monitor: the monitor config can now be simplified to use a number for the monitor index since you no longer need to specify the work_area_offset. So you can now do this:
"monitor": 0, // remember that the old version still works...

Using these new options after removing the old ones, the bar will automatically calculate the correct work_area_offset for you and apply it. So you don't need to worry about it at all!

Example:

Lets say you wanted a bar like this:
image

Notice that it has some margin on top, but on the bottom is just the normal workspace_padding + container_padding from komorebi. The bar has a height of 80. And a top margin of 10.

BEFORE:

You would need to set the following:

"monitor": {
    "index": 0,
    "work_area_offset": {
        "left": 0,
        "top": 90, // needed to be the bar height + start position y
        "right": 0,
        "bottom": 90 // needed to be the bar height + start position y
    }
  },
  "position": {
      "start": {
          "x": 0,
          "y": 10 // this was to set the margin above
      },
      "end": {
          "x": 1920,
          "y": 80 // this would be the bar height
      }
  },
  "frame": {
      "inner_margin": {
          "x": 10,
          "y": 32 // this would be the vertical padding of the bar
      }
  },
full config
{
  "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/master/schema.bar.json",
  "monitor": {
    "index": 0,
    "work_area_offset": {
        "left": 0,
        "top": 90,
        "right": 0,
        "bottom": 90
    }
  },
  "position": {
      "start": {
          "x": 0,
          "y": 10
      },
      "end": {
          "x": 1920,
          "y": 80
      }
  },
  "frame": {
      "inner_margin": {
          "x": 10,
          "y": 32
      }
  },
  "grouping": {
      "kind": "Widget",
      "rounding": 16.0,
      "transparency_alpha": 200
  },
  "transparency_alpha": 113,
  "max_label_width": 250,
  "font_family": "JetBrains Mono",
  "theme": {
    "palette": "Base16",
    "name": "TokyoNightStorm",
    "accent": "Base0D"
  },
  "left_widgets": [
    {
      "Komorebi": {
        "workspaces": {
          "enable": true,
          "hide_empty_workspaces": false,
          "display": "Text"
        },
        "layout": {
          "enable": true,
          "display": "Icon"
        }
      }
    }
  ],
  "center_widgets": [
    {
      "Komorebi": {
        "focused_window": {
          "enable": true,
          "display": "IconAndTextOnSelected"
        }
      }
    }
  ],
  "right_widgets": [
    {
      "Battery": {
        "enable": true
      }
    },
    {
      "Date": {
        "enable": true,
        "format": "DayDateMonthYear"
      }
    },
    {
      "Time": {
        "enable": true,
        "format": "TwentyFourHour"
      }
    }
  ]
}

AFTER:

Now you only need this:

  "monitor": 0,
  "height": 80,
  "margin": { "vertical": [10, 0] },
  "padding": { "vertical": 32 },
full config
{
  "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/master/schema.bar.json",
  "monitor": 0,
  "height": 80,
  "margin": { "vertical": [10, 0] },
  "padding": { "vertical": 32 },
  "grouping": {
      "kind": "Widget",
      "rounding": 16.0,
      "transparency_alpha": 200
  },
  "transparency_alpha": 113,
  "max_label_width": 250,
  "font_family": "JetBrains Mono",
  "theme": {
    "palette": "Base16",
    "name": "TokyoNightStorm",
    "accent": "Base0D"
  },
  "left_widgets": [
    {
      "Komorebi": {
        "workspaces": {
          "enable": true,
          "hide_empty_workspaces": false,
          "display": "Text"
        },
        "layout": {
          "enable": true,
          "display": "Icon"
        }
      }
    }
  ],
  "center_widgets": [
    {
      "Komorebi": {
        "focused_window": {
          "enable": true,
          "display": "IconAndTextOnSelected"
        }
      }
    }
  ],
  "right_widgets": [
    {
      "Battery": {
        "enable": true
      }
    },
    {
      "Date": {
        "enable": true,
        "format": "DayDateMonthYear"
      }
    },
    {
      "Time": {
        "enable": true,
        "format": "TwentyFourHour"
      }
    }
  ]
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/LGUG2Z/komorebi/pull/1224 **Author:** [@alex-ds13](https://github.com/alex-ds13) **Created:** 1/10/2025 **Status:** ✅ Merged **Merged:** 1/23/2025 **Merged by:** [@LGUG2Z](https://github.com/LGUG2Z) **Base:** `master` ← **Head:** `fix(bar)/simplify-bar-config` --- ### 📝 Commits (2) - [`0093d82`](https://github.com/LGUG2Z/komorebi/commit/0093d82d2decd38197b331712f8a687b22c2f3f6) fix(bar): simplify config for bar - [`45ffb89`](https://github.com/LGUG2Z/komorebi/commit/45ffb893fc192185986c781ad82e3caffa94ad40) fix(bar): pass reconnect event to bar ### 📊 Changes **7 files changed** (+707 additions, -230 deletions) <details> <summary>View changed files</summary> 📝 `docs/komorebi.bar.example.json` (+1 -9) 📝 `komorebi-bar/src/bar.rs` (+217 -54) 📝 `komorebi-bar/src/config.rs` (+216 -3) 📝 `komorebi-bar/src/komorebi.rs` (+80 -97) 📝 `komorebi-bar/src/main.rs` (+34 -34) 📝 `komorebi-bar/src/render.rs` (+7 -1) 📝 `schema.bar.json` (+152 -32) </details> ### 📄 Description Old users will still be able to use the old options, however it should be discouraged or even deprecated to use the following configs: ### Configs to remove: - `work_area_offset` inside `monitor` - `position` - `frame` If you remove all the options above the bar will still show up with a default height of 50 and a default padding of 10 all around. If you need to customize the bar height, padding or margin you should use these new options: ### New Configs: - `height`: the height you want for the bar itself - `margin`: this option allows you to set a margin around the bar (`default: 0`). You can either set it like this: ```jsonc "margin": 10 // It will use a spacing of 10 on all sides of the bar ``` or like this: ```jsonc "margin": { "vertical": 10 // It will use a spacing of 10 above and below the bar } ``` or like this (`vertical` and `horizontal` are optional you can set only one axis and the other will be left at default value): ```jsonc "margin": { "vertical": [10, 0], // It will use a spacing of 10 above the bar but no spacing below "horizontal": 10, // It will use a spacing of 10 on the left and right sides of the bar } ``` or even like this to specify each side individually: ```jsonc "margin": { "top": 10, "bottom": 0, "left": 0, "right": 0 } ``` - `padding`: this option allows you to set a padding inside the bar (`default: 10` on all sides). The higher the padding the smaller the widgets will be, if the vertical padding is set at 0 the widgets will try to fill the entire height of the bar. This option can be set just like the margin above. ### Changed Configs: - `monitor`: the monitor config can now be simplified to use a number for the monitor index since you no longer need to specify the `work_area_offset`. So you can now do this: ```jsonc "monitor": 0, // remember that the old version still works... ``` Using these new options after removing the old ones, the bar will automatically calculate the correct `work_area_offset` for you and apply it. So you don't need to worry about it at all! ## Example: Lets say you wanted a bar like this: ![image](https://github.com/user-attachments/assets/9550747f-44a8-4a9f-bce7-b3faef0791ef) Notice that it has some margin on top, but on the bottom is just the normal `workspace_padding` + `container_padding` from komorebi. The bar has a height of 80. And a top margin of 10. ### BEFORE: You would need to set the following: ```jsonc "monitor": { "index": 0, "work_area_offset": { "left": 0, "top": 90, // needed to be the bar height + start position y "right": 0, "bottom": 90 // needed to be the bar height + start position y } }, "position": { "start": { "x": 0, "y": 10 // this was to set the margin above }, "end": { "x": 1920, "y": 80 // this would be the bar height } }, "frame": { "inner_margin": { "x": 10, "y": 32 // this would be the vertical padding of the bar } }, ``` <details> <summary>full config</summary> ```json { "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/master/schema.bar.json", "monitor": { "index": 0, "work_area_offset": { "left": 0, "top": 90, "right": 0, "bottom": 90 } }, "position": { "start": { "x": 0, "y": 10 }, "end": { "x": 1920, "y": 80 } }, "frame": { "inner_margin": { "x": 10, "y": 32 } }, "grouping": { "kind": "Widget", "rounding": 16.0, "transparency_alpha": 200 }, "transparency_alpha": 113, "max_label_width": 250, "font_family": "JetBrains Mono", "theme": { "palette": "Base16", "name": "TokyoNightStorm", "accent": "Base0D" }, "left_widgets": [ { "Komorebi": { "workspaces": { "enable": true, "hide_empty_workspaces": false, "display": "Text" }, "layout": { "enable": true, "display": "Icon" } } } ], "center_widgets": [ { "Komorebi": { "focused_window": { "enable": true, "display": "IconAndTextOnSelected" } } } ], "right_widgets": [ { "Battery": { "enable": true } }, { "Date": { "enable": true, "format": "DayDateMonthYear" } }, { "Time": { "enable": true, "format": "TwentyFourHour" } } ] } ``` </details> ### AFTER: Now you only need this: ```json "monitor": 0, "height": 80, "margin": { "vertical": [10, 0] }, "padding": { "vertical": 32 }, ``` <details> <summary>full config</summary> ```json { "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/master/schema.bar.json", "monitor": 0, "height": 80, "margin": { "vertical": [10, 0] }, "padding": { "vertical": 32 }, "grouping": { "kind": "Widget", "rounding": 16.0, "transparency_alpha": 200 }, "transparency_alpha": 113, "max_label_width": 250, "font_family": "JetBrains Mono", "theme": { "palette": "Base16", "name": "TokyoNightStorm", "accent": "Base0D" }, "left_widgets": [ { "Komorebi": { "workspaces": { "enable": true, "hide_empty_workspaces": false, "display": "Text" }, "layout": { "enable": true, "display": "Icon" } } } ], "center_widgets": [ { "Komorebi": { "focused_window": { "enable": true, "display": "IconAndTextOnSelected" } } } ], "right_widgets": [ { "Battery": { "enable": true } }, { "Date": { "enable": true, "format": "DayDateMonthYear" } }, { "Time": { "enable": true, "format": "TwentyFourHour" } } ] } ``` </details> <!-- Please follow the Conventional Commits specification. If you need to update your PR with changes from `master`, please run `git rebase master`. By opening this PR, you confirm that you have read and understood this project's `CONTRIBUTING.md`. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2026-01-05 14:54:41 +01:00
adam closed this issue 2026-01-05 14:54:41 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/komorebi#1264