mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merge pull request #724 from madepolli/modded_resourceusage
modded resourceusage
This commit is contained in:
commit
59501353e7
@ -12,11 +12,13 @@ const (
|
||||
|
||||
type Settings struct {
|
||||
common *cfg.Common
|
||||
cpuCombined bool
|
||||
}
|
||||
|
||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||
settings := Settings{
|
||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||
cpuCombined: ymlConfig.UBool("cpuCombined"),
|
||||
}
|
||||
|
||||
return &settings
|
||||
|
@ -44,7 +44,8 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
||||
|
||||
// MakeGraph - Load the dead drop stats
|
||||
func MakeGraph(widget *Widget) {
|
||||
cpuStats, err := cpu.Percent(time.Duration(0), true)
|
||||
|
||||
cpuStats, err := cpu.Percent(time.Duration(0), !widget.settings.cpuCombined)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -56,8 +57,15 @@ func MakeGraph(widget *Widget) {
|
||||
stat = math.Min(100, stat)
|
||||
stat = math.Max(0, stat)
|
||||
|
||||
var label string
|
||||
if (widget.settings.cpuCombined) {
|
||||
label = "CPU"
|
||||
} else {
|
||||
label = fmt.Sprint(i)
|
||||
}
|
||||
|
||||
bar := view.Bar{
|
||||
Label: fmt.Sprint(i),
|
||||
Label: label,
|
||||
Percent: int(stat),
|
||||
ValueLabel: fmt.Sprintf("%d%%", int(stat)),
|
||||
LabelColor: "red",
|
||||
@ -119,9 +127,8 @@ func (widget *Widget) Refresh() {
|
||||
return
|
||||
}
|
||||
|
||||
widget.View.Clear()
|
||||
|
||||
widget.app.QueueUpdateDraw(func() {
|
||||
widget.View.Clear()
|
||||
display(widget)
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user