eww icon indicating copy to clipboard operation
eww copied to clipboard

add `formatbytes` to expressions

Open topongo opened this issue 6 months ago • 1 comments

Description

add the formatbytes function to eww expressions. this is a format successor of #1271, by leveraging the bytesize crate we can format byte numbers (very common on eww, see EWW_NET, EWW_DISK) in a human readable format.

Usage

  • formatbytes(bytes, short, format_mode): Display bytes in a human-readable format. Arguments:
    • bytes: i64 of bytes, supports negative sizes.
    • short: set true for a compact version (default: false)
    • format_mode: set to either to "iec" (eg. 1.0 GiB) or "si" (eg. 1.2 GB) (default: "iec")

Showcase

image

Checklist

Please make sure you can check all the boxes that apply to this PR.

  • [x] All widgets I've added are correctly documented.
  • [x] I added my changes to CHANGELOG.md, if appropriate.
  • [x] The documentation in the docs/content/main directory has been adjusted to reflect my changes.
  • [x] I used cargo fmt to automatically format all code before committing

topongo avatar Jun 09 '25 15:06 topongo

i apologize for not noticing #1277... i guess this is a duplicate then. the implementation is similar, apart the fact that i'm using an external crate for the actual format.

topongo avatar Jun 09 '25 22:06 topongo