2022-09-07 15:09:50 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-09-07 17:28:27 +02:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
2022-09-07 15:09:50 +02:00
|
|
|
)
|
|
|
|
|
2022-09-07 17:28:27 +02:00
|
|
|
func getHostname() string {
|
|
|
|
cmd := exec.Command("uname", "-n")
|
|
|
|
shell, _ := cmd.Output()
|
|
|
|
return strings.Replace(string(shell), "\n", "", -1)
|
|
|
|
}
|
|
|
|
func getUsername() string {
|
|
|
|
cmd := exec.Command("whoami")
|
|
|
|
shell, _ := cmd.Output()
|
|
|
|
return strings.Replace(string(shell), "\n", "", -1)
|
|
|
|
}
|
2022-09-07 15:09:50 +02:00
|
|
|
func getLogo() {
|
|
|
|
}
|
2022-09-07 17:28:27 +02:00
|
|
|
func getDistro() string {
|
2022-09-07 15:09:50 +02:00
|
|
|
distro, err := os.Open("/etc/os-release")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Error:", err)
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
distro_info := make([]byte, 1024)
|
|
|
|
distro.Read(distro_info)
|
|
|
|
distro.Close()
|
|
|
|
distro_list := strings.Split(string(distro_info), "\n")
|
|
|
|
distro_tuples := make(map[string]string)
|
|
|
|
for _, v := range distro_list {
|
|
|
|
if strings.Contains(v, "=") {
|
|
|
|
kv := strings.Split(v, "=")
|
|
|
|
kv[0] = strings.TrimSpace(kv[0])
|
|
|
|
kv[1] = strings.TrimSpace(kv[1])
|
|
|
|
distro_tuples[kv[0]] = kv[1]
|
|
|
|
}
|
|
|
|
}
|
2022-09-07 17:28:27 +02:00
|
|
|
return strings.Trim(distro_tuples["PRETTY_NAME"], "\"")
|
2022-09-07 15:09:50 +02:00
|
|
|
}
|
|
|
|
func getKernel() string {
|
2022-09-07 17:28:27 +02:00
|
|
|
cmd := exec.Command("uname", "-r")
|
|
|
|
kernel, err := cmd.Output()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
return "fuck you"
|
|
|
|
}
|
|
|
|
return string(kernel)
|
2022-09-07 15:09:50 +02:00
|
|
|
}
|
|
|
|
func getUptime() {
|
2022-09-07 17:28:27 +02:00
|
|
|
|
2022-09-07 15:09:50 +02:00
|
|
|
}
|
|
|
|
func getPackages() {
|
|
|
|
}
|
|
|
|
func getShell() string {
|
2022-09-07 17:28:27 +02:00
|
|
|
return os.Getenv("SHELL")
|
2022-09-07 15:09:50 +02:00
|
|
|
}
|
|
|
|
func getResolution() {
|
2022-09-07 17:28:27 +02:00
|
|
|
|
2022-09-07 15:09:50 +02:00
|
|
|
}
|
|
|
|
func getWM() {
|
|
|
|
}
|
|
|
|
func getTheme() {
|
|
|
|
}
|
|
|
|
func getIcons() {
|
|
|
|
}
|
|
|
|
func getTerminal() {
|
|
|
|
}
|
|
|
|
func getCPU() {
|
|
|
|
}
|
2022-09-07 17:28:27 +02:00
|
|
|
func getGPU() string {
|
|
|
|
cmd := exec.Command("lspci", "-v")
|
|
|
|
shell, err := cmd.Output()
|
|
|
|
_ = err
|
|
|
|
var bruh string
|
|
|
|
//return strings.Replace(string(shell), "\n", "", -1)
|
|
|
|
//return string(shell)
|
|
|
|
for _, line := range strings.Split(strings.TrimSuffix(string(shell), "\n"), "\n") {
|
|
|
|
if strings.Contains(line, "VGA") {
|
|
|
|
bruh += line[strings.Index(line, ": ")+2 : strings.Index(line, " (")]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bruh
|
2022-09-07 15:09:50 +02:00
|
|
|
}
|
2022-09-07 17:28:27 +02:00
|
|
|
func getMemory() string {
|
2022-09-07 15:09:50 +02:00
|
|
|
|
2022-09-07 17:28:27 +02:00
|
|
|
//
|
|
|
|
// The coolest part about this function unlike neofetch is that it also takes account of the basic os operations
|
|
|
|
// into account thus not giving an illusion that your os is completely having fun
|
|
|
|
// honestly idk lmao
|
|
|
|
//
|
|
|
|
|
|
|
|
mem, err := os.Open("/proc/meminfo")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
os.Exit(0)
|
|
|
|
}
|
|
|
|
mem_info := make([]byte, 1024)
|
|
|
|
mem.Read(mem_info)
|
|
|
|
mem.Close()
|
|
|
|
mem_list := strings.Split(string(mem_info), "\n")
|
|
|
|
mem_map := make(map[string]string)
|
|
|
|
for _, v := range mem_list {
|
|
|
|
if strings.Contains(v, ":") {
|
|
|
|
kv := strings.Split(v, ":")
|
|
|
|
kv[0] = strings.TrimSpace(kv[0])
|
|
|
|
kv[1] = strings.TrimSpace(kv[1])
|
|
|
|
kv[1] = strings.Replace(kv[1], "kB", "", 3)
|
|
|
|
kv[1] = strings.TrimSpace(kv[1])
|
|
|
|
mem_map[kv[0]] = kv[1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mem_free, _ := strconv.Atoi(mem_map["MemFree"])
|
|
|
|
mem_total, _ := strconv.Atoi(mem_map["MemTotal"])
|
|
|
|
mem_used := mem_total - mem_free
|
|
|
|
memory := fmt.Sprintf("%d/%d", mem_used/1024, mem_total/1024)
|
|
|
|
return (memory)
|
2022-09-07 15:09:50 +02:00
|
|
|
}
|
|
|
|
|
2022-09-07 17:28:27 +02:00
|
|
|
func getColorPalette() {
|
|
|
|
}
|
2022-09-07 15:09:50 +02:00
|
|
|
|
|
|
|
func main() {
|
2022-09-07 17:28:27 +02:00
|
|
|
/*just for testing, dont use these lmao im gonna make an config file
|
|
|
|
fmt.Println(getHostname(), "@", getUsername())
|
|
|
|
fmt.Println(getDistro())
|
|
|
|
fmt.Println(getGPU())
|
|
|
|
fmt.Println(getMemory())
|
|
|
|
fmt.Println(getKernel())
|
|
|
|
*/
|
2022-09-07 15:09:50 +02:00
|
|
|
}
|