1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

modded resourceusage

This commit is contained in:
Matjaž Depolli 2019-10-25 12:54:16 +02:00
parent c230853364
commit 900d0d0ea5
2 changed files with 13 additions and 4 deletions

View File

@ -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

View File

@ -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)
})
}