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

Add roundsize function #926

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add roundsize function #926

wants to merge 4 commits into from

Conversation

Bouk250
Copy link

@Bouk250 Bouk250 commented Sep 23, 2023

Description

I added a function for easily pars size value into human-readable value.

Usage

;; RAM Stats Widgets ;;
(defwidget ram_stats [used_mem total_mem]
      (label
        :text `${round(used_mem.size,2)}${used_mem.units}/${round(total_mem.size,0)}${total_mem.units}`)
    )
  )

;; Stats Widgets ;;
(defwidget stats []
    (ram_stats 
    :total_mem {roundsize(EWW_RAM.total_mem)}
    :used_mem {roundsize(EWW_RAM.used_mem)})
  )
)

Showcase

It's help to parse magic variable that provide size in bytes without external script

Checklist

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

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

@elkowar
Copy link
Owner

elkowar commented Feb 17, 2024

Not sure I'm a fan of having this return JSON, tbh -- wouldn't just having a "formatbytecount" function or something like that that takes a number of bytes and turns it into a string with the appropriate unit be sufficient?

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.

None yet

2 participants