Skip to content
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
1 change: 1 addition & 0 deletions include/modules/hyprland/language.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Language : public waybar::ALabel, public EventHandler {
util::JsonParser parser_;

Layout layout_;
std::string tooltip_format_;

IPC& m_ipc;
};
Expand Down
13 changes: 13 additions & 0 deletions man/waybar-hyprland-language.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ Addressed by *hyprland/language*
typeof: string ++
Specifies which keyboard to use from hyprctl devices output. Using the option that begins with "at-translated-set..." is recommended.

*tooltip-format*: ++
typeof: string ++
default: {} ++
The format, how layout should be displayed in tooltip. If omitted,
the tooltip displays the same layout text as the module. Supports the
same format replacements as *format*.

*tooltip*: ++
typeof: bool ++
default: true ++
Option to disable tooltip on hover.

*menu*: ++
typeof: string ++
Action that popups the menu.
Expand Down Expand Up @@ -60,6 +72,7 @@ Addressed by *hyprland/language*
```
"hyprland/language": {
"format": "Lang: {long}",
"tooltip-format": "Layout: {long}",
"format-en": "AMERICA, HELL YEAH!",
"format-tr": "As bayrakları",
"keyboard-name": "at-translated-set-2-keyboard"
Expand Down
16 changes: 16 additions & 0 deletions src/modules/hyprland/language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ namespace waybar::modules::hyprland {

Language::Language(const std::string& id, const Bar& bar, const Json::Value& config)
: ALabel(config, "language", id, "{}", 0, true), bar_(bar), m_ipc(IPC::inst()) {
if (config.isMember("tooltip-format")) {
tooltip_format_ = config["tooltip-format"].asString();
}

// get the active layout when open
initLanguage();

Expand Down Expand Up @@ -54,6 +58,18 @@ auto Language::update() -> void {
if (!format_.empty()) {
label_.show();
label_.set_markup(layoutName);
if (tooltipEnabled()) {
if (!tooltip_format_.empty()) {
auto tooltip_display_layout = trim(fmt::format(
fmt::runtime(tooltip_format_), fmt::arg("long", layout_.full_name),
fmt::arg("short", layout_.short_name),
fmt::arg("shortDescription", layout_.short_description),
fmt::arg("variant", layout_.variant)));
label_.set_tooltip_markup(tooltip_display_layout);
} else {
label_.set_tooltip_markup(layoutName);
}
}
} else {
label_.hide();
}
Expand Down