Add docs and adjust sorting
This commit is contained in:
parent
0ad29a5960
commit
42b6c089f3
|
@ -0,0 +1,69 @@
|
||||||
|
waybar-wlr-workspaces(5)
|
||||||
|
|
||||||
|
# NAME
|
||||||
|
|
||||||
|
waybar - wlr workspaces module
|
||||||
|
|
||||||
|
# DESCRIPTION
|
||||||
|
|
||||||
|
The *workspaces* module displays the currently used workspaces in waynland compositor.
|
||||||
|
|
||||||
|
# CONFIGURATION
|
||||||
|
|
||||||
|
Addressed by *wlr/workspaces*
|
||||||
|
|
||||||
|
*format*: ++
|
||||||
|
typeof: string ++
|
||||||
|
default: {name} ++
|
||||||
|
The format, how information should be displayed.
|
||||||
|
|
||||||
|
*format-icons*: ++
|
||||||
|
typeof: array ++
|
||||||
|
Based on the workspace name and state, the corresponding icon gets selected. See *icons*.
|
||||||
|
|
||||||
|
*sort-by-name*: ++
|
||||||
|
typeof: bool ++
|
||||||
|
default: true ++
|
||||||
|
Should workspaces be sorted by name.
|
||||||
|
|
||||||
|
*sort-by-coordinates*: ++
|
||||||
|
typeof: bool ++
|
||||||
|
default: false ++
|
||||||
|
Should workspaces be sorted by coordinates.
|
||||||
|
Note that if both *sort-by-name* and *sort-by-coordinates* are true sort by name will be first.
|
||||||
|
If both are false - sort by id will be performed.
|
||||||
|
|
||||||
|
# FORMAT REPLACEMENTS
|
||||||
|
|
||||||
|
*{name}*: Number stripped from workspace value.
|
||||||
|
|
||||||
|
*{icon}*: Icon, as defined in *format-icons*.
|
||||||
|
|
||||||
|
# ICONS
|
||||||
|
|
||||||
|
Additional to workspace name matching, the following *format-icons* can be set.
|
||||||
|
|
||||||
|
- *default*: Will be shown, when no string matches is found.
|
||||||
|
- *focused*: Will be shown, when workspace is focused
|
||||||
|
|
||||||
|
# EXAMPLES
|
||||||
|
|
||||||
|
```
|
||||||
|
"wlr/workspaces": {
|
||||||
|
"format": "{name}: {icon}",
|
||||||
|
"format-icons": {
|
||||||
|
"1": "",
|
||||||
|
"2": "",
|
||||||
|
"3": "",
|
||||||
|
"4": "",
|
||||||
|
"5": "",
|
||||||
|
"focused": "",
|
||||||
|
"default": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
# Style
|
||||||
|
|
||||||
|
- *#workspaces button*
|
||||||
|
- *#workspaces button.focused*
|
|
@ -197,5 +197,6 @@ Valid options for the "rotate" property are: 0, 90, 180 and 270.
|
||||||
- *waybar-sway-window(5)*
|
- *waybar-sway-window(5)*
|
||||||
- *waybar-sway-workspaces(5)*
|
- *waybar-sway-workspaces(5)*
|
||||||
- *waybar-wlr-taskbar(5)*
|
- *waybar-wlr-taskbar(5)*
|
||||||
|
- *waybar-wlr-workspaces(5)*
|
||||||
- *waybar-temperature(5)*
|
- *waybar-temperature(5)*
|
||||||
- *waybar-tray(5)*
|
- *waybar-tray(5)*
|
||||||
|
|
|
@ -272,6 +272,7 @@ if scdoc.found()
|
||||||
'waybar-tray.5.scd',
|
'waybar-tray.5.scd',
|
||||||
'waybar-states.5.scd',
|
'waybar-states.5.scd',
|
||||||
'waybar-wlr-taskbar.5.scd',
|
'waybar-wlr-taskbar.5.scd',
|
||||||
|
'waybar-wlr-workspaces.5.scd',
|
||||||
'waybar-bluetooth.5.scd',
|
'waybar-bluetooth.5.scd',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -101,12 +101,12 @@ WorkspaceGroup::WorkspaceGroup(const Bar &bar, Gtk::Box &box, const Json::Value
|
||||||
workspace_group_handle_(workspace_group_handle),
|
workspace_group_handle_(workspace_group_handle),
|
||||||
id_(id) {
|
id_(id) {
|
||||||
add_workspace_group_listener(workspace_group_handle, this);
|
add_workspace_group_listener(workspace_group_handle, this);
|
||||||
auto config_sort_by_name = config_["sort_by_name"];
|
auto config_sort_by_name = config_["sort-by-name"];
|
||||||
if (config_sort_by_name.isBool()) {
|
if (config_sort_by_name.isBool()) {
|
||||||
sort_by_name = config_sort_by_name.asBool();
|
sort_by_name = config_sort_by_name.asBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto config_sort_by_coordinates = config_["sort_by_coordinates"];
|
auto config_sort_by_coordinates = config_["sort-by-coordinates"];
|
||||||
if (config_sort_by_coordinates.isBool()) {
|
if (config_sort_by_coordinates.isBool()) {
|
||||||
sort_by_coordinates = config_sort_by_coordinates.asBool();
|
sort_by_coordinates = config_sort_by_coordinates.asBool();
|
||||||
}
|
}
|
||||||
|
@ -180,12 +180,25 @@ auto WorkspaceGroup::commit() -> void { workspace_manager_.commit(); }
|
||||||
|
|
||||||
auto WorkspaceGroup::sort_workspaces() -> void {
|
auto WorkspaceGroup::sort_workspaces() -> void {
|
||||||
auto cmp = [=](std::unique_ptr<Workspace> &lhs, std::unique_ptr<Workspace> &rhs) {
|
auto cmp = [=](std::unique_ptr<Workspace> &lhs, std::unique_ptr<Workspace> &rhs) {
|
||||||
if (sort_by_name && lhs->get_name() != rhs->get_name()) {
|
auto is_name_less = lhs->get_name() < rhs->get_name();
|
||||||
return lhs->get_name() < rhs->get_name();
|
auto is_name_eq = lhs->get_name() == rhs->get_name();
|
||||||
|
auto is_coords_less = lhs->get_coords() < rhs->get_coords();
|
||||||
|
if (sort_by_name) {
|
||||||
|
if (sort_by_coordinates) {
|
||||||
|
return is_name_eq ? is_coords_less : is_name_less;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return is_name_less;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return lhs->get_coords() < rhs->get_coords();
|
if (sort_by_coordinates) {
|
||||||
|
return is_coords_less;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lhs->id() < rhs->id();
|
||||||
};
|
};
|
||||||
|
|
||||||
std::sort(workspaces_.begin(), workspaces_.end(), cmp);
|
std::sort(workspaces_.begin(), workspaces_.end(), cmp);
|
||||||
for (size_t i = 0; i < workspaces_.size(); ++i) {
|
for (size_t i = 0; i < workspaces_.size(); ++i) {
|
||||||
for (auto &workspace : workspaces_) {
|
for (auto &workspace : workspaces_) {
|
||||||
|
|
Loading…
Reference in New Issue