Skip to content

[BUG] formatbytes errors with EWW_RAM.used_mem (used_mem is an f32) #1424

Description

@lazy-orb-weaver

Checklist before submitting an issue

  • I have searched through the existing closed and open issues for eww and made sure this is not a duplicate
  • I have specifically verified that this bug is not a common user error
  • I am providing as much relevant information as I am able to in this bug report (Minimal config to reproduce the issue for example, if applicable)

Description of the bug

The EWW_RAM.used_mem magic variable cannot be used in formatbytes without being cast to an int through floor/ceil, which is inconsistent with the other memory magics that return bytes as integers

Reproducing the issue

This will happily display available mem, but error for used mem.

(defwindow example
           :monitor 0
           :geometry (geometry :x 0 :y 0 :anchor "top center")
           :stacking "fg" :windowtype "dock"
           (box :orientation "horizontal"
                "used_mem: ${formatbytes(EWW_RAM.used_mem, true, 'iec')}"
                "|"
                "available_mem: ${formatbytes(EWW_RAM.available_mem, true, 'iec')}"))

Expected behaviour

Expected this to work
"${formatbytes(EWW_RAM.used_mem, true, 'iec'}"
like this does
"${formatbytes(EWW_RAM.available_mem, true, 'iec')}"

Additional context

Error output:

error: Failed to turn 15014653952.0 into a value of type i64
┌─ /home/USER/.config/eww/eww.yuck:52:30
│
52 │ "${formatbytes(EWW_RAM.used_mem, true, 'iec')}"

Other memory information uses the sysinfo crate and it looks like that returns u64's, while used_mem explicitly casts them to f32 to do its subtraction.

Platform and environment

Wayland
Niri
eww 0.6.0 865cf63

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions