Skip to content

Conversation

@MagicFab
Copy link

Add used / total GB disk space used info to Disk widget

Add used / total GB disk space used info to Disk widget
@MagicFab
Copy link
Author

image

@sopex
Copy link
Contributor

sopex commented Aug 25, 2025

I like it :)

const totalBytes = usedBytes + freeBytes;
const usedGB = this._formatGB(usedBytes);
const totalGB = this._formatGB(totalBytes);
return `(${usedGB}/${totalGB}) GB`;
Copy link
Member

Choose a reason for hiding this comment

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

The () looks misplaced before the GB, may be better to just omit and free the space used by it.

Copy link
Author

Choose a reason for hiding this comment

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

It looks the same as the memory widget, but I agree the parenthesis aren't useful. Then the memory widget would have to be adjusted (easily done).

*/

_formatGB(bytes) {
return (bytes / (1000 * 1000 * 1000)).toFixed(1);
Copy link
Member

Choose a reason for hiding this comment

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

I think this is too simplistic as it should adapt to k M G T...

Copy link
Member

Choose a reason for hiding this comment

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

This kind of formatter could be added to the BaseWidget I think.

E.g. here is one the UI uses in multiple places.

function byteFormat(bytes, decimals)

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that would make more sense. My reasoning was that storage for such a device would be within XX GB and XXX GB - but we know how that ends up :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants