// $TheSupernovaDuo: mima,v 2024.08.20 2023/08/20 09:53:10 yakumo_izuru Exp $ // // Get current system information like neofetch(1) without fancy things. package main import ( "fmt" "github.com/shirou/gopsutil/v3/host" "github.com/shirou/gopsutil/v3/mem" "log" "os" "runtime" _ "embed" ) //go:embed mima_embed var mima string func main() { hostname, err := os.Hostname() uptime, _ := host.Uptime() v, _ := mem.VirtualMemory() days := uptime / (60 * 60 * 24) hours := (uptime - (days * 60 * 60 * 24)) / (60 * 60) minutes := ((uptime - (days * 60 * 60 * 24)) - (hours * 60 * 60)) / 60 free_mem := v.Free / 1024 / 1024 total_mem := v.Total / 1024 / 1024 kernelversion, err := host.KernelVersion() if err != nil { log.Fatal(err) } fmt.Printf("%s\n", mima) fmt.Printf("%s @ %s\n", os.Getenv("USER"), hostname) fmt.Printf("\n") fmt.Printf("Editor:\t%s\n", os.Getenv("EDITOR")) fmt.Printf("System:\t%s\n", runtime.GOOS) fmt.Printf("Kernel:\t%s\n", kernelversion) fmt.Printf("Architecture:\t%s\n", runtime.GOARCH) fmt.Printf("RAM:\t%vM/%vM (%f%%)\n", free_mem, total_mem, v.UsedPercent) fmt.Printf("Shell:\t%s\n", os.Getenv("SHELL")) fmt.Printf("Uptime:\t%dd:%dh:%dm\n", days, hours, minutes) }