Skip to content

Commit 6a4dfca

Browse files
committed
feat: implement about screen
1 parent 2484620 commit 6a4dfca

File tree

2 files changed

+1659
-220
lines changed

2 files changed

+1659
-220
lines changed

display.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ import (
55
"fmt"
66
"os"
77
"strconv"
8+
"strings"
89
"sync"
910
"time"
11+
12+
"github.com/prometheus/common/version"
1013
)
1114

1215
var currentScreen = "boot_screen"
@@ -161,8 +164,33 @@ func updateStaticContents() {
161164
if err == nil {
162165
nativeInstance.UpdateLabelIfChanged("boot_screen_version", systemVersion.String())
163166
nativeInstance.UpdateLabelIfChanged("boot_screen_app_version", appVersion.String())
167+
nativeInstance.UpdateLabelIfChanged("system_version_label", systemVersion.String())
168+
nativeInstance.UpdateLabelIfChanged("app_version_label", appVersion.String())
169+
}
170+
171+
// get cpu info
172+
cpuInfo, err := os.ReadFile("/proc/cpuinfo")
173+
// get the line starting with "Serial"
174+
for _, line := range strings.Split(string(cpuInfo), "\n") {
175+
if strings.HasPrefix(line, "Serial") {
176+
serial := strings.SplitN(line, ":", 2)[1]
177+
nativeInstance.UpdateLabelIfChanged("cpu_serial_label", strings.TrimSpace(serial))
178+
break
179+
}
164180
}
165181

182+
// get kernel version
183+
kernelVersion, err := os.ReadFile("/proc/version")
184+
if err == nil {
185+
kernelVersion := strings.TrimPrefix(string(kernelVersion), "Linux version ")
186+
kernelVersion = strings.SplitN(kernelVersion, " ", 2)[0]
187+
nativeInstance.UpdateLabelIfChanged("kernel_version_label", kernelVersion)
188+
}
189+
190+
nativeInstance.UpdateLabelIfChanged("build_branch_label", version.Branch)
191+
nativeInstance.UpdateLabelIfChanged("build_date_label", version.BuildDate)
192+
nativeInstance.UpdateLabelIfChanged("golang_version_label", version.GoVersion)
193+
166194
nativeInstance.UpdateLabelIfChanged("boot_screen_device_id", GetDeviceID())
167195
}
168196

0 commit comments

Comments
 (0)