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

upower: show-icon config option #2703

Merged
merged 3 commits into from
Dec 5, 2023
Merged
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/upower/upower.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class UPower : public AModule {
std::unique_ptr<UPowerTooltip> upower_tooltip;
std::string lastStatus;
bool showAltText;
bool showIcon = true;
bool upowerRunning;
guint upowerWatcher_id;
std::string nativePath_;
Expand Down
14 changes: 14 additions & 0 deletions man/waybar-upower.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ compatible devices in the tooltip.
typeof: string ++
Command to execute when clicked on the module.

*show-icon*: ++
typeof: bool ++
default: true ++
Option to disable battery icon.

# FORMAT REPLACEMENTS

*{percentage}*: The battery capacity in percentage
Expand Down Expand Up @@ -93,6 +98,15 @@ depending on the charging state.
"tooltip": true,
"tooltip-spacing": 20
}
```
```
"upower": {
"show-icon": false,
"hide-if-empty": true,
"tooltip": true,
"tooltip-spacing": 20
}

```

# STYLE
Expand Down
10 changes: 9 additions & 1 deletion src/modules/upower/upower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ UPower::UPower(const std::string& id, const Json::Value& config)
m_Mutex(),
client(),
showAltText(false) {
box_.pack_start(icon_);
// Show icon only when "show-icon" isn't set to false
if (config_["show-icon"].isBool()) {
showIcon = config_["show-icon"].asBool();
}

if (showIcon) {
box_.pack_start(icon_);
}

box_.pack_start(label_);
box_.set_name(name_);
event_box_.add(box_);
Expand Down