mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merge branch 'master' of https://github.com/senorprogrammer/wtf
fixed conflict. Signed-off-by: Mike Lloyd <mike@reboot3times.org>
This commit is contained in:
@@ -2,6 +2,7 @@ package system
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
@@ -18,7 +19,16 @@ func NewSystemInfo() *SystemInfo {
|
||||
|
||||
arg := []string{}
|
||||
|
||||
cmd := exec.Command("sw_vers", arg...)
|
||||
var cmd *exec.Cmd
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
cmd = exec.Command("uname -a", arg...)
|
||||
case "darwin":
|
||||
cmd = exec.Command("sw_vers", arg...)
|
||||
default:
|
||||
cmd = exec.Command("sw_vers", arg...)
|
||||
}
|
||||
|
||||
raw := wtf.ExecuteCommand(cmd)
|
||||
|
||||
for _, row := range strings.Split(raw, "\n") {
|
||||
@@ -31,11 +41,27 @@ func NewSystemInfo() *SystemInfo {
|
||||
m[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1])
|
||||
}
|
||||
|
||||
sysInfo := SystemInfo{
|
||||
ProductName: m["ProductName"],
|
||||
ProductVersion: m["ProductVersion"],
|
||||
BuildVersion: m["BuildVersion"],
|
||||
}
|
||||
var sysInfo *SystemInfo
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
sysInfo = &SystemInfo{
|
||||
ProductName: m["Distributor ID"],
|
||||
ProductVersion: m["Description"],
|
||||
BuildVersion: m["Release"],
|
||||
}
|
||||
case "darwin":
|
||||
sysInfo = &SystemInfo{
|
||||
ProductName: m["ProductName"],
|
||||
ProductVersion: m["ProductVersion"],
|
||||
BuildVersion: m["BuildVersion"],
|
||||
}
|
||||
default:
|
||||
sysInfo = &SystemInfo{
|
||||
ProductName: m["ProductName"],
|
||||
ProductVersion: m["ProductVersion"],
|
||||
BuildVersion: m["BuildVersion"],
|
||||
}
|
||||
|
||||
return &sysInfo
|
||||
}
|
||||
return sysInfo
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ type Widget struct {
|
||||
|
||||
func NewWidget(date, version string) *Widget {
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" Build ", "system", false),
|
||||
TextWidget: wtf.NewTextWidget(" System ", "system", false),
|
||||
|
||||
Date: date,
|
||||
Version: version,
|
||||
@@ -38,19 +38,19 @@ func (widget *Widget) Refresh() {
|
||||
}
|
||||
|
||||
widget.UpdateRefreshedAt()
|
||||
widget.View.Clear()
|
||||
|
||||
fmt.Fprintf(
|
||||
widget.View,
|
||||
"%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,
|
||||
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,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user