feat(sysinfo): add disks

resolves #1710
This commit is contained in:
Jan De Dobbeleer 2022-02-06 13:52:10 +01:00 committed by Jan De Dobbeleer
parent 47e6658978
commit 7a60418297
2 changed files with 11 additions and 2 deletions

View file

@ -13,10 +13,9 @@ Display SysInfo.
```json
{
"type":"sysinfo",
"powerline_symbol": "",
"powerline_symbol": "\ue0b0",
"foreground": "#ffffff",
"background": "#8f43f3",
"invert_powerline": true,
"properties": {
"precision": 2,
"template":" \uf85a {{ round .PhysicalPercentUsed .Precision }}% "
@ -51,6 +50,8 @@ Display SysInfo.
- `.Load5`: `float64` - is the current load5 (can be empty on windows)
- `.Load15`: `float64` - is the current load15 (can be empty on windows)
- `.CPU`: `[]struct` - an array of [InfoStat][cpuinfo] object, you can use any property it has e.g. `(index .CPU 0).Cores`
- `.Disks`: `[]struct` - an array of [IOCountersStat][ioinfo] object, you can use any property it has e.g. `.Disks.disk0.IoTime`
[cpuinfo]: https://github.com/shirou/gopsutil/blob/78065a7ce2021f6a78c8d6f586a2683ba501dcec/cpu/cpu.go#L32
[ioinfo]: https://github.com/shirou/gopsutil/blob/e0ec1b9cda4470db704a862282a396986d7e930c/disk/disk.go#L32
[templates]: /docs/config-templates

View file

@ -5,6 +5,7 @@ import (
"oh-my-posh/properties"
cpu "github.com/shirou/gopsutil/v3/cpu"
disk "github.com/shirou/gopsutil/v3/disk"
load "github.com/shirou/gopsutil/v3/load"
mem "github.com/shirou/gopsutil/v3/mem"
)
@ -28,6 +29,8 @@ type SystemInfo struct {
Load1 float64
Load5 float64
Load15 float64
// disk
Disks map[string]disk.IOCountersStat
}
const (
@ -80,4 +83,9 @@ func (s *SystemInfo) Init(props properties.Properties, env environment.Environme
if err == nil {
s.CPU = processors
}
// disk
diskIO, err := disk.IOCounters()
if err == nil {
s.Disks = diskIO
}
}