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:
2
Makefile
2
Makefile
@@ -11,7 +11,7 @@ all: clean build
|
||||
|
||||
## This target compiles binary
|
||||
build:
|
||||
CGO_ENABLED=0 go build ${BUILDOPTS} -o ${BINARY} ${FILELIST}
|
||||
go build ${BUILDOPTS} -o ${BINARY} ${FILELIST}
|
||||
|
||||
|
||||
## Remove binary with golang compiler' means
|
||||
|
||||
22
memory.go
22
memory.go
@@ -9,9 +9,9 @@ import (
|
||||
|
||||
// Mem struct with mem stats.
|
||||
type Mem struct {
|
||||
Usedpct int64
|
||||
Shared int64
|
||||
Swap int64
|
||||
Usedpct uint64
|
||||
Shared uint64
|
||||
Swap uint64
|
||||
}
|
||||
|
||||
// Memory stores string with mem stats for i3bar.
|
||||
@@ -39,17 +39,17 @@ func UpdateMemStats() {
|
||||
}
|
||||
|
||||
if Conf.Mem.ShowSwap {
|
||||
if Memory.Usedpct != int64(v.UsedPercent) || Memory.Shared != int64(v.Shared/1024/1024) ||
|
||||
Memory.Swap != int64(v.SwapTotal-v.SwapFree) {
|
||||
Memory.Usedpct = int64(v.UsedPercent)
|
||||
Memory.Shared = int64(v.Shared / 1024 / 1024)
|
||||
Memory.Swap = int64(sw.Total - sw.Free)
|
||||
if Memory.Usedpct != uint64(v.UsedPercent) || Memory.Shared != v.Shared/1024/1024 ||
|
||||
Memory.Swap != v.SwapTotal-v.SwapFree {
|
||||
Memory.Usedpct = uint64(v.UsedPercent)
|
||||
Memory.Shared = v.Shared / 1024 / 1024
|
||||
Memory.Swap = sw.Used
|
||||
UpdateReady <- true
|
||||
}
|
||||
} else {
|
||||
if Memory.Usedpct != int64(v.UsedPercent) || Memory.Shared != int64(v.Shared/1024/1024) {
|
||||
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 = uint64(v.UsedPercent)
|
||||
Memory.Shared = v.Shared / 1024 / 1024
|
||||
UpdateReady <- true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user