summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-04-21 16:14:34 -0500
committerSean E. Russell <ser@ser1.net>2020-04-21 16:14:34 -0500
commitdfa7098ad87e645638a52d384eebb178111d073a (patch)
treedf7ed6726174e2d126a2ae503b4f418bc5038f17
parent4895f5ec248b6fa32ae120fdea7ea106a83261a1 (diff)
Fixes #90. The disk widget was truncating, not rounding
-rw-r--r--CHANGELOG.md2
-rw-r--r--widgets/disk.go9
2 files changed, 6 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 43f7437..4d2670e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Help & statusbar don't obey theme (#47).
- Fix help text layout.
- Merged fix from @markuspeloquin for custom color scheme loading crash
+- Memory line colors were inconsistently assigned (#91)
+- The disk code was truncating values instead of rounding (#90)
## [3.5.1] - 2020-04-09
diff --git a/widgets/disk.go b/widgets/disk.go
index 3235a6e..b53df9d 100644
--- a/widgets/disk.go
+++ b/widgets/disk.go
@@ -121,17 +121,16 @@ func (self *DiskWidget) update() {
delete(self.Partitions, device)
}
- // updates partition info
+ // updates partition info. We add 0.5 to all values to make sure the truncation rounds
for _, partition := range self.Partitions {
usage, err := psDisk.Usage(partition.MountPoint)
if err != nil {
log.Printf("failed to get partition usage statistics from gopsutil: %v. partition: %v", err, partition)
continue
}
- partition.UsedPercent = uint32(usage.UsedPercent)
-
+ partition.UsedPercent = uint32(usage.UsedPercent + 0.5)
bytesFree, magnitudeFree := utils.ConvertBytes(usage.Free)
- partition.Free = fmt.Sprintf("%3d%s", uint64(bytesFree), magnitudeFree)
+ partition.Free = fmt.Sprintf("%3d%s", uint64(bytesFree+0.5), magnitudeFree)
ioCounters, err := psDisk.IOCounters(partition.Device)
if err != nil {
@@ -146,7 +145,7 @@ func (self *DiskWidget) update() {
readFloat, readMagnitude := utils.ConvertBytes(bytesReadRecently)
writeFloat, writeMagnitude := utils.ConvertBytes(bytesWrittenRecently)
- bytesReadRecently, bytesWrittenRecently = uint64(readFloat), uint64(writeFloat)
+ bytesReadRecently, bytesWrittenRecently = uint64(readFloat+0.5), uint64(writeFloat+0.5)
partition.BytesReadRecently = fmt.Sprintf("%d%s", bytesReadRecently, readMagnitude)
partition.BytesWrittenRecently = fmt.Sprintf("%d%s", bytesWrittenRecently, writeMagnitude)
} else {