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 {
|
type Settings struct {
|
||||||
common *cfg.Common
|
common *cfg.Common
|
||||||
|
cpuCombined bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||||
|
cpuCombined: ymlConfig.UBool("cpuCombined"),
|
||||||
}
|
}
|
||||||
|
|
||||||
return &settings
|
return &settings
|
||||||
|
@ -44,7 +44,8 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget {
|
|||||||
|
|
||||||
// MakeGraph - Load the dead drop stats
|
// MakeGraph - Load the dead drop stats
|
||||||
func MakeGraph(widget *Widget) {
|
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 {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -56,8 +57,15 @@ func MakeGraph(widget *Widget) {
|
|||||||
stat = math.Min(100, stat)
|
stat = math.Min(100, stat)
|
||||||
stat = math.Max(0, stat)
|
stat = math.Max(0, stat)
|
||||||
|
|
||||||
|
var label string
|
||||||
|
if (widget.settings.cpuCombined) {
|
||||||
|
label = "CPU"
|
||||||
|
} else {
|
||||||
|
label = fmt.Sprint(i)
|
||||||
|
}
|
||||||
|
|
||||||
bar := view.Bar{
|
bar := view.Bar{
|
||||||
Label: fmt.Sprint(i),
|
Label: label,
|
||||||
Percent: int(stat),
|
Percent: int(stat),
|
||||||
ValueLabel: fmt.Sprintf("%d%%", int(stat)),
|
ValueLabel: fmt.Sprintf("%d%%", int(stat)),
|
||||||
LabelColor: "red",
|
LabelColor: "red",
|
||||||
@ -119,9 +127,8 @@ func (widget *Widget) Refresh() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.View.Clear()
|
|
||||||
|
|
||||||
widget.app.QueueUpdateDraw(func() {
|
widget.app.QueueUpdateDraw(func() {
|
||||||
|
widget.View.Clear()
|
||||||
display(widget)
|
display(widget)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user