Merge pull request #4772 from szbmrk/feat-hyprland-submap-icon-handling

feat(hyprland/submap): add config option to specify different icons for submaps
This commit is contained in:
Alexis Rouillard
2026-07-04 00:41:11 +02:00
committed by GitHub
3 changed files with 33 additions and 4 deletions
+2
View File
@@ -26,9 +26,11 @@ class Submap : public waybar::ALabel, public EventHandler {
const Bar& bar_;
util::JsonParser parser_;
std::string submap_;
std::string icon_;
std::string prev_submap_;
bool always_on_ = false;
std::string default_submap_ = "Default";
std::unordered_map<std::string, std::string> icons_;
IPC& m_ipc;
};
+11 -3
View File
@@ -15,7 +15,7 @@ Addressed by *hyprland/submap*
*format*: ++
typeof: string ++
default: {} ++
The format, how information should be displayed. On {} the currently active submap is displayed.
The format, how information should be displayed. This format supports two placeholders: *{submap}* for the currently active submap name and *{icon}* for the icon associated with the submap.
*rotate*: ++
typeof: integer ++
@@ -80,6 +80,10 @@ Addressed by *hyprland/submap*
default: Default ++
Option to set the submap name to display when not in an active submap.
*icons*: ++
typeof: object ++
Based on the submap name, the corresponding icon will be selected from this map and made available as the *{icon}* placeholder in the format string. The keys are submap names, and the values are the icons or strings to display for those submaps.
*menu*: ++
typeof: string ++
Action that popups the menu.
@@ -103,9 +107,13 @@ Addressed by *hyprland/submap*
```
"hyprland/submap": {
"format": "✌️ {}",
"format": "{icon} {submap}",
"max-length": 8,
"tooltip": false
"tooltip": false,
"icons": {
"resize": "",
"pause": "",
}
}
```
+20 -1
View File
@@ -21,6 +21,18 @@ Submap::Submap(const std::string& id, const Bar& bar, const Json::Value& config)
// register for hyprland ipc
m_ipc.registerForIPC("submap", this);
dp.emit();
if (config["icons"].isObject()) {
const Json::Value& icons = config["icons"];
for (const std::string& key : icons.getMemberNames()) {
const Json::Value& value = icons[key];
if (value.isString()) {
icons_[key] = value.asString();
}
}
}
}
Submap::~Submap() {
@@ -58,7 +70,8 @@ auto Submap::update() -> void {
if (submap_.empty()) {
event_box_.hide();
} else {
label_.set_markup(fmt::format(fmt::runtime(format_), submap_));
label_.set_markup(
fmt::format(fmt::runtime(format_), fmt::arg("submap", submap_), fmt::arg("icon", icon_)));
if (tooltipEnabled()) {
label_.set_tooltip_markup(submap_);
}
@@ -84,6 +97,12 @@ void Submap::onEvent(const std::string& ev) {
submap_ = submapName;
if (!icons_[submap_].empty()) {
icon_ = icons_[submap_];
} else {
icon_ = "";
}
if (submap_.empty() && always_on_) {
submap_ = default_submap_;
}