mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
40 lines
684 B
Go
40 lines
684 B
Go
package segments
|
|
|
|
import (
|
|
"github.com/jandedobbeleer/oh-my-posh/src/properties"
|
|
"github.com/jandedobbeleer/oh-my-posh/src/runtime"
|
|
)
|
|
|
|
type SystemInfo struct {
|
|
base
|
|
|
|
runtime.SystemInfo
|
|
Precision int
|
|
}
|
|
|
|
const (
|
|
// Precision number of decimal places to show
|
|
Precision properties.Property = "precision"
|
|
)
|
|
|
|
func (s *SystemInfo) Template() string {
|
|
return " {{ round .PhysicalPercentUsed .Precision }} "
|
|
}
|
|
|
|
func (s *SystemInfo) Enabled() bool {
|
|
s.Precision = s.props.GetInt(Precision, 2)
|
|
|
|
sysInfo, err := s.env.SystemInfo()
|
|
if err != nil {
|
|
return false
|
|
}
|
|
|
|
s.SystemInfo = *sysInfo
|
|
|
|
if s.PhysicalPercentUsed == 0 && s.SwapPercentUsed == 0 {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}
|