mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
When no widget has focus, press the letter key to focus on the widget assigned to that letter. Example: GitHub (d) Press "d" to focus on the GitHub widget.
57 lines
915 B
Go
57 lines
915 B
Go
package system
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/senorprogrammer/wtf/wtf"
|
|
)
|
|
|
|
type Widget struct {
|
|
wtf.TextWidget
|
|
|
|
systemInfo *SystemInfo
|
|
Date string
|
|
Version string
|
|
}
|
|
|
|
func NewWidget(date, version string) *Widget {
|
|
widget := Widget{
|
|
TextWidget: wtf.NewTextWidget("System", "system", false),
|
|
|
|
Date: date,
|
|
Version: version,
|
|
}
|
|
|
|
widget.systemInfo = NewSystemInfo()
|
|
|
|
return &widget
|
|
}
|
|
|
|
func (widget *Widget) Refresh() {
|
|
widget.UpdateRefreshedAt()
|
|
|
|
widget.View.SetText(
|
|
fmt.Sprintf(
|
|
"%8s: %s\n%8s: %s\n\n%8s: %s\n%8s: %s",
|
|
"Built",
|
|
widget.prettyDate(),
|
|
"Vers",
|
|
widget.Version,
|
|
"OS",
|
|
widget.systemInfo.ProductVersion,
|
|
"Build",
|
|
widget.systemInfo.BuildVersion,
|
|
),
|
|
)
|
|
}
|
|
|
|
func (widget *Widget) prettyDate() string {
|
|
str, err := time.Parse(wtf.TimestampFormat, widget.Date)
|
|
if err != nil {
|
|
return err.Error()
|
|
} else {
|
|
return str.Format("Jan _2, 15:04")
|
|
}
|
|
}
|