Skip to content
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

add format-icons to river/layout #3311

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#### Current features
- Sway (Workspaces, Binding mode, Focused window name)
- River (Mapping mode, Tags, Focused window name)
- River (Mapping mode, Tags, Focused window name, Layout)
- Hyprland (Window Icons, Workspaces, Focused window name)
- Niri (Workspaces, Focused window name, Language)
- DWL (Tags, Focused window name) [requires dwl ipc patch](https://github.com/djpohly/dwl/wiki/ipc)
Expand Down
35 changes: 31 additions & 4 deletions man/waybar-river-layout.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ Addressed by *river/layout*

*format*: ++
typeof: string ++
default: {} ++
default: {layout} ++
The format, how information should be displayed. On {} data gets inserted.

*format-icons*: ++
typeof: array ++
Based on the current layout, the corresponding icon gets selected.

*rotate*: ++
typeof: integer ++
Positive value to rotate the text label (in 90 degree increments).
Expand Down Expand Up @@ -64,21 +68,44 @@ Addressed by *river/layout*
typeof: array ++
The actions corresponding to the buttons of the menu.

# EXAMPLE
# FORMAT REPLACEMENTS

*{layout}*: Layout, as defined by your layout generator. By default this will be *rivertile(1)*

*{icon}*: Icon, as defined in *format-icons*

# EXAMPLES

With layout name:

```
"river/layout": {
"format": "{}",
"format": "{layout}",
"min-length": 4,
"align": "right"
}
```

With icons, this sets icons for the 4 layouts available in rivertile:

```
"river/layout": {
"format": "{icon}",
"min-length": 3,
"format-icons": {
"left": "[]=",
"bottom": "TTT",
"top": "ꓕꓕꓕ",
"right": "=[]",
}
}
```

# STYLE

- *#layout*
- *#layout.focused* Applied when the output this module's bar belongs to is focused.

# SEE ALSO

waybar(5), river(1)
waybar(5), river(1), rivertile(1)
4 changes: 3 additions & 1 deletion src/modules/river/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ void Layout::handle_name(const char *name) {
label_.hide(); // hide empty labels or labels with empty format
} else {
label_.show();
label_.set_markup(fmt::format(fmt::runtime(format_), Glib::Markup::escape_text(name).raw()));
std::string escaped_name=Glib::Markup::escape_text(name).raw();
label_.set_markup(fmt::format(fmt::runtime(format_), fmt::arg("layout", name),
fmt::arg("icon", getIcon(0, name))));
}
ALabel::update();
}
Expand Down