add new stats
This commit is contained in:
parent
e8ad780364
commit
01345b0344
30
main.go
30
main.go
@ -7,6 +7,7 @@ import (
|
|||||||
_ "image/png"
|
_ "image/png"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -245,6 +246,31 @@ func getAbsLogoPath(relativePath string) string {
|
|||||||
return relativePath
|
return relativePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getShell() string {
|
||||||
|
out, err := exec.Command("ps", "-p", strconv.Itoa(os.Getppid()), "-o", "comm=").Output()
|
||||||
|
if err != nil {
|
||||||
|
return path.Base(os.Getenv("SHELL"))
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(string(out))
|
||||||
|
}
|
||||||
|
|
||||||
|
func getTerminal() string {
|
||||||
|
return os.Getenv("TERM")
|
||||||
|
}
|
||||||
|
|
||||||
|
func getDE() string {
|
||||||
|
return os.Getenv("XDG_CURRENT_DESKTOP")
|
||||||
|
}
|
||||||
|
|
||||||
|
func getUptime() string {
|
||||||
|
out, err := exec.Command("sh", "-c", "uptime -p").Output()
|
||||||
|
if err != nil {
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
uptime := strings.TrimPrefix(string(out), "up ")
|
||||||
|
return strings.TrimSpace(uptime)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
type Info struct {
|
type Info struct {
|
||||||
Label string
|
Label string
|
||||||
@ -265,7 +291,11 @@ func main() {
|
|||||||
{"krnl", getKernel()},
|
{"krnl", getKernel()},
|
||||||
{"ram", getRam()},
|
{"ram", getRam()},
|
||||||
{"gpu", getGpu()},
|
{"gpu", getGpu()},
|
||||||
|
{"de/wm", getDE()},
|
||||||
{"pkgs", getPkgs()},
|
{"pkgs", getPkgs()},
|
||||||
|
{"shell", getShell()},
|
||||||
|
{"term", getTerminal()},
|
||||||
|
{"uptime", getUptime()},
|
||||||
}
|
}
|
||||||
|
|
||||||
logoPath := flag.String("l", absoluteDefaultLogo, "Absolute or relative path to the logo image")
|
logoPath := flag.String("l", absoluteDefaultLogo, "Absolute or relative path to the logo image")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user