diff options
| author | Christine Dodrill <xena@yolo-swag.com> | 2015-03-10 22:14:28 -0700 |
|---|---|---|
| committer | Christine Dodrill <xena@yolo-swag.com> | 2015-03-10 22:14:28 -0700 |
| commit | d7b1077d29ca831235907b5436bea901a643045f (patch) | |
| tree | 4ad8c8c7ba549c96b245ce9a35d0fbbb869d1bc9 | |
| parent | 3e08f9090b89373273609b123c0baaeb4c73ad20 (diff) | |
| download | x-d7b1077d29ca831235907b5436bea901a643045f.tar.xz x-d7b1077d29ca831235907b5436bea901a643045f.zip | |
logo: show package count, cpu name, uptime, username, hostname
| -rw-r--r-- | logo/logo.go | 10 | ||||
| -rw-r--r-- | logo/logo_openbsd.go | 33 |
2 files changed, 35 insertions, 8 deletions
diff --git a/logo/logo.go b/logo/logo.go index b688075..d0599a2 100644 --- a/logo/logo.go +++ b/logo/logo.go @@ -12,7 +12,15 @@ func main() { color := ansi.ColorCode("white+b:green") fmt.Print(color) - fmt.Printf(logo, 0, 0, 0, "Fast", getUptime(), getUsername(), getHostname()) + fmt.Printf( + logo, + "", + getPackageCount(), + getCPUName(), + getUptime(), + getUsername(), + getHostname(), + ) fmt.Println(ansi.ColorCode("reset")) } diff --git a/logo/logo_openbsd.go b/logo/logo_openbsd.go index a465fcf..b6d20e0 100644 --- a/logo/logo_openbsd.go +++ b/logo/logo_openbsd.go @@ -4,6 +4,7 @@ import ( "fmt" "os/exec" "strconv" + "strings" "time" "github.com/mgutz/ansi" @@ -15,13 +16,13 @@ var ( ) var logo string = ` ____ - /____\ ` + reset + " Ram: %dM/%dM" + color + ` - |\ | __________.__ __ .__ ` + reset + " Pacakges: %d" + color + ` - | \ | \______ \__|/ |________|__| ____ ` + reset + " CPU: %s" + color + ` - | \ | | | _/ \ __\_ __ \ |/ ___\ ` + reset + " Uptime: %s" + color + ` - |___\| | | \ || | | | \/ / /_/ > ` + reset + " User: %s" + color + ` - | /| |______ /__||__| |__| |__\___ / ` + reset + " Hostname: %s" + color + ` - | / | \/ /_____/ + /____\ ` + reset + " Ram: %s" + color + ` + |\ | __________.__ __ .__ ` + reset + " Pacakges: %d" + color + ` + | \ | \______ \__|/ |________|__| ____ ` + reset + " CPU: %s" + color + ` + | \ | | | _/ \ __\_ __ \ |/ ___\ ` + reset + " Uptime: %s" + color + ` + |___\| | | \ || | | | \/ / /_/ > ` + reset + " User: %s" + color + ` + | /| |______ /__||__| |__| |__\___ / ` + reset + " Hostname: %s" + color + ` + | / | \/ /_____/ | / | |/ __| Version 1.0 | |___________________________________________` @@ -46,3 +47,21 @@ func getUptime() string { return fmt.Sprintf("%d days, %d hours, %d minutes", days, hours, minutes) } + +func getPackageCount() int { + out, err := exec.Command("pkg_info").Output() + if err != nil { + panic(err) + } + + return len(strings.Split(string(out), "\n")) +} + +func getCPUName() string { + out, err := exec.Command("sysctl", "-n", "hw.model").Output() + if err != nil { + panic(err) + } + + return strings.Split(string(out), "@")[0] +} |
