mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
27 lines
342 B
Go
27 lines
342 B
Go
package widgets
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
ui "github.com/gizak/termui"
|
|
)
|
|
|
|
type CPU struct {
|
|
*ui.Gauge
|
|
}
|
|
|
|
func NewCPU() *CPU {
|
|
return &CPU{mkGauge()}
|
|
}
|
|
|
|
func (c *CPU) Set(val int) {
|
|
c.BarColor = colorScale(val)
|
|
c.Label = fmt.Sprintf("%s%%", strconv.Itoa(val))
|
|
if val < 5 {
|
|
val = 5
|
|
c.BarColor = ui.ColorBlack
|
|
}
|
|
c.Percent = val
|
|
}
|