-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix(bar): simplify bar config #1224
Conversation
dbe7148
to
49121ce
Compare
Finally got some time to check this out this weekend. On the whole I'm happy with these changes, but I want to make sure that existing configs will look the same as they did before after applying the changes in this PR Same configuration file: {
"$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/refs/heads/master/schema.bar.json",
"monitor": {
"index": 0,
"work_area_offset": {
"left": 0,
"top": 40,
"right": 0,
"bottom": 40
}
},
"font_family": "JetBrains Mono",
"transparency_alpha": 0,
"position": {
"start": {
"x": 20.0,
"y": 0.0
},
"end": {
"x": 5080.0,
"y": 50.0
}
},
"grouping": {
"kind": "Widget",
"style": "DefaultWithShadowB4O1S3",
"rounding": 5,
"transparency_alpha": 255
},
"left_widgets": [
{
"Komorebi": {
"workspaces": {
"enable": true,
"hide_empty_workspaces": false
},
"layout": {
"enable": false,
"display": "Icon"
},
"focused_window": {
"enable": true,
"display": "IconAndText"
}
}
}
],
"center_widgets": [],
"right_widgets": [
// {
// "Update": {
// "enable": true
// }
// },
{
"Media": {
"enable": true
}
},
{
"Storage": {
"enable": false
}
},
{
"Cpu": {
"enable": true
}
},
{
"Memory": {
"enable": true
}
},
{
"Network": {
"enable": true,
"show_default_interface": false,
"show_total_data_transmitted": false,
"show_network_activity": true
}
},
{
"Date": {
"enable": true,
"format": "DayDateMonthYear"
}
},
{
"Time": {
"enable": true,
"format": "TwentyFourHour"
}
}
]
} |
Actually on second thought and after playing around with this a little more, I think that this small discrepancy is fine because it makes everything else more consistent when you change the settings |
Can you do an interactive rebase on this to make it a single commit? 🙏 |
d1b6761
to
69c54fb
Compare
Is it ok like this? I can't get a reference to the commits themselves like you do sometimes since they are on my fork... |
# This is a combination of 9 commits. # This is the 1st commit message: fix(bar): add simplified config for bar This commit creates a few new config options for the bar that should make it a lot simpler for new users to configure the bar. - Remove the need for `position`: if a position is given the bar will still use it with priority over the new config. Instead of position you can now use the following: - `height`: defines the height of the bar (50 by default) - `horizontal_margin`: defines the left and right offset of the bar, it is the same as setting a `position.start.x` and then remove the same amount on `position.end.x`. - `vertical_margin`: defines the top and bottom offset of the bar, it is the same as setting a `position.start.y` and then add a correct amount on the `work_area_offset`. - Remove the need for `frame`: some new configs were added that take priority over the old `frame`. These are: - `horizontal_padding`: defines the left and right padding of the bar. Similar to `frame.inner_margin.x`. - `vertical_padding`: defines the top and bottom padding of the bar. Similar to `frame.inner_margin.y`. - Remove the need for `work_area_offset`: if a `work_area_offset` is given then it will take priority, if not, then it will calculate the necessary `work_area_offset` using the bar height, position and horizontal and vertical margins. # This is the commit message n.2: feat(bar): set margin/padding as one or two values This commit changes the `horizontal_margin`, `vertical_margin`, `horizontal_padding` and `vertical_padding` to now take a `SpacingAxisConfig` which can take a single value or two values. For example, you can set the vertical margin of the bar to add some spacing above and below like this: ```json "vertical_margin": 10 ``` Which will add a spacing of 10 above and below the bar. Or you can set it like this: ```json "vertical_margin": [10, 0] ``` Which will add a spacing of 10 above the bar but no spacing below. You can even set something like this: ```json "vertical_margin": [0, -10] ``` To make no spacing above and a negative spacing below to make it so the tiled windows show right next to the bar. This will basically be removing the workspace and container padding between the tiled windows and the bar. # This is the commit message n.3: fix(bar): use a right_to_left layout on right side This commit changes the right area with the right widgets to have a different layout that is still right_to_left as previously but behaves much better in regards to its height. # This is the commit message n.4: fix(bar): use default bar height When there is no `work_area_offset` and no `height` on the config it was using the `BAR_HEIGHT` as default, however the automatica work_area_offset calculation wasn't being done properly. Now it is! # This is the commit message n.5: feat(bar): monitor can be `MonitorConfig` or index This commit allows the `"monitor":` config to take a `MonitorConfig` object like it used to or simply a number (index). # This is the commit message n.6: docs(schema): update all json schemas # This is the commit message n.7: fix(bar): update example bar config # This is the commit message n.8: fix(bar): correct work_area_offset on secondary monitors # This is the commit message n.9: feat(bar): add multiple options for margin/padding This commit removes the previous `horizontal_margin`, `vertical_margin`, `horizontal_padding` and `vertical_padding`, replacing them all with just `margin` and `padding`. These new options can be set either with a single value that sets that spacing on all sides, with an object specifying each individual side or with an object specifying some "vertical" and/or "horizontal" spacing which can have a single value, resulting on a symmetric spacing for that specific axis or two values to define each side of the axis individually.
69c54fb
to
0093d82
Compare
This commit changes the `rx_gui` from receiving just a notification from komorebi to now receive a new type `KomorebiEvent` which can be either a `KomorebiEvent::Notification(komorebi_client::Notification)` or a `KomorebiEvent::Reconnect`. The `Reconnect` is sent after losing connection with komorebi and then reconnecting again. Now on the bar `update` we check for this `rx_gui` if we get a notification we pass that to the `KomorebiNotificationState::handle_notification` function just like before (except now it takes a notification directly instead of taking the `rx_gui` and checking for some message on the channel). If instead we get a `Reconnect` we send a `MonitorWorkAreaOffset` socket message to komorebi to update the work area offset.
This interactively rebased commit is comprised of the subsequent individual commits listed further below. At a high level: - work_area_offset is now automatically calculated by default - monitor can now take an index in addition to the previous object - position can largely be replaced by margin and padding for bars that are positioned at the top of the screen - frame can now largely be replaced by margin and padding for bars that are positioned at the top of the screen - height is now a more intuitive configuration option for setting the height of the bar Detailed explainations and examples are included in the body of PR #1224 on GitHub: #1224 fix(bar): add simplified config for bar This commit creates a few new config options for the bar that should make it a lot simpler for new users to configure the bar. - Remove the need for `position`: if a position is given the bar will still use it with priority over the new config. Instead of position you can now use the following: - `height`: defines the height of the bar (50 by default) - `horizontal_margin`: defines the left and right offset of the bar, it is the same as setting a `position.start.x` and then remove the same amount on `position.end.x`. - `vertical_margin`: defines the top and bottom offset of the bar, it is the same as setting a `position.start.y` and then add a correct amount on the `work_area_offset`. - Remove the need for `frame`: some new configs were added that take priority over the old `frame`. These are: - `horizontal_padding`: defines the left and right padding of the bar. Similar to `frame.inner_margin.x`. - `vertical_padding`: defines the top and bottom padding of the bar. Similar to `frame.inner_margin.y`. - Remove the need for `work_area_offset`: if a `work_area_offset` is given then it will take priority, if not, then it will calculate the necessary `work_area_offset` using the bar height, position and horizontal and vertical margins. feat(bar): set margin/padding as one or two values This commit changes the `horizontal_margin`, `vertical_margin`, `horizontal_padding` and `vertical_padding` to now take a `SpacingAxisConfig` which can take a single value or two values. For example, you can set the vertical margin of the bar to add some spacing above and below like this: ```json "vertical_margin": 10 ``` Which will add a spacing of 10 above and below the bar. Or you can set it like this: ```json "vertical_margin": [10, 0] ``` Which will add a spacing of 10 above the bar but no spacing below. You can even set something like this: ```json "vertical_margin": [0, -10] ``` To make no spacing above and a negative spacing below to make it so the tiled windows show right next to the bar. This will basically be removing the workspace and container padding between the tiled windows and the bar. fix(bar): use a right_to_left layout on right side This commit changes the right area with the right widgets to have a different layout that is still right_to_left as previously but behaves much better in regards to its height. fix(bar): use default bar height When there is no `work_area_offset` and no `height` on the config it was using the `BAR_HEIGHT` as default, however the automatica work_area_offset calculation wasn't being done properly. Now it is! feat(bar): monitor can be `MonitorConfig` or index This commit allows the `"monitor":` config to take a `MonitorConfig` object like it used to or simply a number (index). docs(schema): update all json schemas fix(bar): update example bar config fix(bar): correct work_area_offset on secondary monitors feat(bar): add multiple options for margin/padding This commit removes the previous `horizontal_margin`, `vertical_margin`, `horizontal_padding` and `vertical_padding`, replacing them all with just `margin` and `padding`. These new options can be set either with a single value that sets that spacing on all sides, with an object specifying each individual side or with an object specifying some "vertical" and/or "horizontal" spacing which can have a single value, resulting on a symmetric spacing for that specific axis or two values to define each side of the axis individually.
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
insidemonitor
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 itselfmargin
: this option allows you to set a margin around the bar (default: 0
). You can either set it like this:or like this:
or like this (
vertical
andhorizontal
are optional you can set only one axis and the other will be left at default value):or even like this to specify each side individually:
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 thework_area_offset
. So you can now do this: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:
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:
full config
AFTER:
Now you only need this:
full config