
Signed-off-by: Aoi K <koizumi.aoi@kyoko-project.wer.ee> git-svn-id: file:///srv/svn/repo/mima/trunk@13 d2428f92-30f9-164c-8098-19ee57ce342c
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
// $KyokoNet: antifetch, v 0.1.6 2022/11/15 08:54:00 akoizumi Exp $
|
|
//
|
|
// Get current system information like neofetch(1) without fancy things.
|
|
// It mostly uses the standard library, and an extra dependency.
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"log"
|
|
"runtime"
|
|
"github.com/shirou/gopsutil/v3/host"
|
|
"github.com/shirou/gopsutil/v3/mem"
|
|
)
|
|
|
|
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
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
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("Architecture:\t%s\n", runtime.GOARCH)
|
|
fmt.Printf("RAM:\t%v/%v (%f%%)\n", v.Total, v.Free, v.UsedPercent)
|
|
fmt.Printf("Shell:\t%s\n", os.Getenv("SHELL"))
|
|
fmt.Printf("Uptime:\t%dd:%dh:%dm\n", days, hours, minutes)
|
|
}
|