Omit type casting, hopefully it can fix bug with swap calculation, also do not explicitly disable cgo, it can be usefull in some cases

This commit is contained in:
eleksir
2024-01-10 22:27:28 +03:00
parent c969ac9e42
commit b0b297bc56
2 changed files with 12 additions and 12 deletions

View File

@@ -11,7 +11,7 @@ all: clean build
## This target compiles binary ## This target compiles binary
build: build:
CGO_ENABLED=0 go build ${BUILDOPTS} -o ${BINARY} ${FILELIST} go build ${BUILDOPTS} -o ${BINARY} ${FILELIST}
## Remove binary with golang compiler' means ## Remove binary with golang compiler' means

View File

@@ -9,9 +9,9 @@ import (
// Mem struct with mem stats. // Mem struct with mem stats.
type Mem struct { type Mem struct {
Usedpct int64 Usedpct uint64
Shared int64 Shared uint64
Swap int64 Swap uint64
} }
// Memory stores string with mem stats for i3bar. // Memory stores string with mem stats for i3bar.
@@ -39,17 +39,17 @@ func UpdateMemStats() {
} }
if Conf.Mem.ShowSwap { if Conf.Mem.ShowSwap {
if Memory.Usedpct != int64(v.UsedPercent) || Memory.Shared != int64(v.Shared/1024/1024) || if Memory.Usedpct != uint64(v.UsedPercent) || Memory.Shared != v.Shared/1024/1024 ||
Memory.Swap != int64(v.SwapTotal-v.SwapFree) { Memory.Swap != v.SwapTotal-v.SwapFree {
Memory.Usedpct = int64(v.UsedPercent) Memory.Usedpct = uint64(v.UsedPercent)
Memory.Shared = int64(v.Shared / 1024 / 1024) Memory.Shared = v.Shared / 1024 / 1024
Memory.Swap = int64(sw.Total - sw.Free) Memory.Swap = sw.Used
UpdateReady <- true UpdateReady <- true
} }
} else { } else {
if Memory.Usedpct != int64(v.UsedPercent) || Memory.Shared != int64(v.Shared/1024/1024) { if Memory.Usedpct != uint64(v.UsedPercent) || Memory.Shared != v.Shared/1024/1024 {
Memory.Usedpct = int64(v.UsedPercent) Memory.Usedpct = uint64(v.UsedPercent)
Memory.Shared = int64(v.Shared / 1024 / 1024) Memory.Shared = v.Shared / 1024 / 1024
UpdateReady <- true UpdateReady <- true
} }
} }