Skip to content

feat(disk)!: handle multiple disks at once#4762

Open
szbmrk wants to merge 1 commit intoAlexays:masterfrom
szbmrk:feat-multiple-disks
Open

feat(disk)!: handle multiple disks at once#4762
szbmrk wants to merge 1 commit intoAlexays:masterfrom
szbmrk:feat-multiple-disks

Conversation

@szbmrk
Copy link

@szbmrk szbmrk commented Jan 9, 2026

Summary

This PR adds support for monitoring multiple disks/mountpoints simultaneously in the disk module.

Breaking Changes

  • The path configuration option is deprecated in favor of paths array
  • Existing configurations using path will continue to work with a deprecation warning

New Configuration Options

  • paths: Array of paths to monitor (default: ["/"])
  • header: Optional text displayed before disk information (default: "")
  • separator: Text separator between disk entries (default: " ")

Example Configuration

"disk": {
    "interval": 30,
    "paths": ["/", "/home"],
    "header": "Disks: ",
    "separator": " ",
    "format": "{percentage_free}% free on {path}"
}

@szbmrk
Copy link
Author

szbmrk commented Jan 10, 2026

I know that this is possible to do this multiple disk handling with workarounds and multiple widgets. But for me for example one of the reasons why i implemented this is the tooltip, so if i only have for example a label like disks and hover over it i can see all my different disk information in one tooltip (i haven't found a workaround for it with the current disk widget).

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for monitoring multiple disks simultaneously in the disk module. The module previously supported only a single disk path, and now supports an array of paths with configurable header and separator text.

Changes:

  • Added support for multiple disk paths via new paths array configuration option
  • Deprecated single path option with backward compatibility and warning
  • Added header and separator configuration options for customizing multi-disk display

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.

File Description
include/modules/disk.hpp Updated member variables: replaced path_ string with paths_ vector, added header_ and separator_ strings
src/modules/disk.cpp Modified constructor to parse new configuration options; refactored update() to loop over multiple paths and aggregate disk information
man/waybar-disk.5.scd Updated documentation to describe new configuration options and usage examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 73 to 92
*paths*: ++
typeof: array ++
default: ["/"] ++
Array of paths residing in the filesystem or mountpoint for which the information should be displayed.

*header*: ++
typeof: string ++
default: "" ++
Text to appear before the disk information defined in the format.

*separator*: ++
typeof: string ++
default: " " ++
Separator string between multiple disk informations.

Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecated "path" configuration option is not documented. Since the PR description states this is a breaking change with backward compatibility and existing configurations using "path" will continue to work with a deprecation warning, the documentation should mention this deprecated option and indicate that users should migrate to "paths".

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

util::SleeperThread thread_;
std::string path_;
std::string header_;
std::vector<std::string> paths_;
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The header file uses std::vector but does not include the vector header. While this may compile due to transitive includes, it's fragile and violates best practices. Add #include <vector> to the includes section.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 105 to 119
std::string tooltip_format = "{used} used out of {total} on {path} ({percentage_used}%)";
if (config_["tooltip-format"].isString()) {
tooltip_format = config_["tooltip-format"].asString();
}
label_.set_tooltip_text(fmt::format(
fmt::runtime(tooltip_format), stats.f_bavail * 100 / stats.f_blocks, fmt::arg("free", free),
fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks), fmt::arg("used", used),
fmt::arg("percentage_used", percentage_used), fmt::arg("total", total),
fmt::arg("path", path_), fmt::arg("specific_free", specific_free),
fmt::arg("specific_used", specific_used), fmt::arg("specific_total", specific_total)));

tooltip_label +=
fmt::format(fmt::runtime(tooltip_format), stats.f_bavail * 100 / stats.f_blocks,
fmt::arg("free", free),
fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks),
fmt::arg("used", used), fmt::arg("percentage_used", percentage_used),
fmt::arg("total", total), fmt::arg("path", path),
fmt::arg("specific_free", specific_free),
fmt::arg("specific_used", specific_used),
fmt::arg("specific_total", specific_total)) +
(i < paths_.size() - 1 ? "\n" : "");
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When disk_format is empty, the disk information is skipped in the label (lines 90-103) but is still added to the tooltip (lines 105-119). This creates an inconsistency where the tooltip might show information for disks that aren't displayed in the label. The tooltip generation should also be conditional on the format not being empty.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 90 to 93
if (disk_format.empty()) {
event_box_.hide();
} else {
event_box_.show();
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The event_box_.hide() and show() calls inside the loop (lines 91 and 93) cause the visibility state to toggle on every iteration. The final visibility depends on the last disk processed, not on whether any valid disk information exists. This should be refactored: collect all valid disk information first, then show/hide the box once after the loop based on whether any valid data was collected. For example, track whether any disk had valid content, and only call show/hide after the loop completes.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

fmt::arg("specific_free", specific_free),
fmt::arg("specific_used", specific_used),
fmt::arg("specific_total", specific_total)) +
(i < paths_.size() - 1 ? separator_ : "");
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separator logic is fragile when some disks have empty formats or fail to load. If the last disk in paths_ has an empty format, previous disks will still add separators based on their index, potentially leaving a trailing separator in the output. The separator should only be added if there are more valid disks to display after the current one, not just based on the array index.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

fmt::arg("specific_free", specific_free),
fmt::arg("specific_used", specific_used),
fmt::arg("specific_total", specific_total)) +
(i < paths_.size() - 1 ? "\n" : "");
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same separator issue affects tooltips: if the last disk has an empty format or fails to load, there could be a trailing newline in the tooltip text.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@szbmrk
Copy link
Author

szbmrk commented Feb 4, 2026

@Alexays i implemented all the suggestions.

@szbmrk szbmrk force-pushed the feat-multiple-disks branch from da94e58 to ca0b068 Compare February 4, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant