Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Memory bar display fails if anything other than 'mib' is used for memory_unit #2008

Open
1 task done
claytonjroberts opened this issue Dec 22, 2021 · 2 comments
Open
1 task done

Comments

@claytonjroberts
Copy link

claytonjroberts commented Dec 22, 2021

Description

When using a bar for memory info (memory_display="bar"), I must have the following in the config file:

memory_unit="mib"

If I have something like the following in the config:

memory_unit="gib"

I get this error:

/usr/local/bin/neofetch: line 4583: 18.50 * bar_length / 32.00: syntax error: invalid arithmetic operator (error token is ".50 * bar_length / 32.00")

Note: I'm running via just neofetch -v

  • Does this issue still occur in the master branch? (Required if issue)

Neofetch version

7.1.0

Screenshot

Screen Shot 2021-12-22 at 1 17 00 AM

Config file

https://gist.github.com/ClaymasterJ/00b8702da639c0ccc2913e7802dc8a56
(^ Working config)

Verbose log

https://pastebin.com/nyfwNbLP

@deergit
Copy link

deergit commented Feb 16, 2023

I fixed this by changing lines 2655 and 2656:

2655: - mem_used=$(awk '{printf "%.2f", $1 / $2}' <<< "$mem_used 1024")
2656: - mem_total=$(awk '{printf "%.2f", $1 / $2}' <<< "$mem_total 1024")

2655: + mem_used=$(awk '{printf "%.0f", $1 / $2}' <<< "$mem_used 1024")
2656: + mem_total=$(awk '{printf "%.0f", $1 / $2}' <<< "$mem_total 1024")

the math fails because bash doesn't handle floats, however if we change the floats to have no decimals it can work again

@hykilpikonna
Copy link

This issue was fixed in #2225

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants