imagine neofetch, but OwO - +
@@ -13,48 +17,8 @@ The information by default is displayed alongside your operating system's uwuifi
You can further configure NeOwOfetch to your horrible taste. Through the use of command-line flags and idfk i havent implemented it yet.
-NeOwOfetch supports almost like 2 different operating systems. From Linux to Linux. If your favourite operating system is unsupported i dont give a shit, ill get to it when i get to it. for now its just arch and ubuntu
+NeOwOfetch supports almost like 2 different operating systems. From Linux to Linux. If your favourite operating system is unsupported i dont give a shit, ill get to it when i get to it. for now its just arch and ubuntu
-jokes aside, the asciiarts are from uwufetch, all credits go to them.
+jokes aside, the asciiarts are from uwufetch, all credits go to them. \ No newline at end of file diff --git a/asciiarts/alpine.txt b/asciiarts/alpine.txt index 3520e07..41409b6 100644 --- a/asciiarts/alpine.txt +++ b/asciiarts/alpine.txt @@ -4,3 +4,5 @@ /OωO\ɛU\/ __ / \ \__/ \ / \ \ + + diff --git a/asciiarts/amog.txt b/asciiarts/amog.txt deleted file mode 100644 index ab0d48b..0000000 --- a/asciiarts/amog.txt +++ /dev/null @@ -1,4 +0,0 @@ - ┌──┐ -┌┤ █▋ -└┤┌┐│ - └┘└┘ \ No newline at end of file diff --git a/asciiarts/android.txt b/asciiarts/android.txt index 2ac1afb..6045cfc 100644 --- a/asciiarts/android.txt +++ b/asciiarts/android.txt @@ -3,3 +3,6 @@ / \ | {RED}~ {GREEN}> ω < {RED}~ {GREEN}| ------------ + + + diff --git a/asciiarts/arch.txt b/asciiarts/arch.txt index 2055997..d4e77f8 100644 --- a/asciiarts/arch.txt +++ b/asciiarts/arch.txt @@ -5,3 +5,4 @@ / __ \ / __| |__-\ /_-'' ''-_\ + diff --git a/asciiarts/archcraft.txt b/asciiarts/archcraft.txt deleted file mode 100644 index 2055997..0000000 --- a/asciiarts/archcraft.txt +++ /dev/null @@ -1,7 +0,0 @@ -{BLUE} /\ - / \ - /\ \ - / > ω <\ - / __ \ - / __| |__-\ - /_-'' ''-_\ diff --git a/asciiarts/arcolinux.txt b/asciiarts/arcolinux.txt index 9992c67..307c35e 100644 --- a/asciiarts/arcolinux.txt +++ b/asciiarts/arcolinux.txt @@ -1,7 +1,7 @@ -{BLUE} /\ - / \ - / \ - /{WHITE}O vv O{BLUE}\ +{BLUE} /\ + / \ + / \ + /{WHITE}O vv O{BLUE}\ / / \ \ - / / __\ \ + / / __\ \ /__/ `\___\ \ No newline at end of file diff --git a/asciiarts/asciiart.go b/asciiarts/asciiart.go index d66b419..b76e9df 100644 --- a/asciiarts/asciiart.go +++ b/asciiarts/asciiart.go @@ -1,20 +1,28 @@ package asciiarts import ( - "embed" - "regexp" + _ "embed" + "strings" ) -//go:embed *.txt -var asciifiles embed.FS +//go:embed alpine.txt +var Alpine string -func GetAscii(distroID string) string { - regex, _ := regexp.Compile("{[[:upper:]]+}") - asciiBuff, error := asciifiles.ReadFile(distroID + ".txt") - if error != nil { - asciiBuff, _ = asciifiles.ReadFile("unknown.txt") +//go:embed unknown.txt +var unknown string + +func GetAsciiInternal(distroID string) string { + switch distroID { + case "Alpine": + return Alpine + default: + return unknown } - ascii := string(asciiBuff) - ascii = regex.ReplaceAllString(ascii, "") +} +func GetAscii(distroID string) string { + ascii := GetAsciiInternal(distroID) + ascii = strings.ReplaceAll(ascii, "{WHITE}", "") + ascii = strings.ReplaceAll(ascii, "{YELLOW}", "") + ascii = strings.ReplaceAll(ascii, "{BLUE}", "") return ascii } diff --git a/asciiarts/debian.txt b/asciiarts/debian.txt index daa40bf..54a85ea 100644 --- a/asciiarts/debian.txt +++ b/asciiarts/debian.txt @@ -4,3 +4,5 @@ | \____- -_ --_\ + + \ No newline at end of file diff --git a/asciiarts/freebsd.txt b/asciiarts/freebsd.txt index 995ac84..3b44a43 100644 --- a/asciiarts/freebsd.txt +++ b/asciiarts/freebsd.txt @@ -5,3 +5,4 @@ | O ω O | ; ; '-_____-' + diff --git a/asciiarts/gentoo.txt b/asciiarts/gentoo.txt index d18587e..7924ef4 100644 --- a/asciiarts/gentoo.txt +++ b/asciiarts/gentoo.txt @@ -5,3 +5,4 @@ / _/ ( _- \\____- + diff --git a/asciiarts/gnu.txt b/asciiarts/gnu.txt index d09a222..eea2a71 100644 --- a/asciiarts/gnu.txt +++ b/asciiarts/gnu.txt @@ -5,3 +5,4 @@ `-'{YELLOW}(. .){WHITE}`-' {YELLOW}\{WHITE}w{YELLOW}/ ¯ + diff --git a/asciiarts/guix.txt b/asciiarts/guix.txt index d09a222..eea2a71 100644 --- a/asciiarts/guix.txt +++ b/asciiarts/guix.txt @@ -5,3 +5,4 @@ `-'{YELLOW}(. .){WHITE}`-' {YELLOW}\{WHITE}w{YELLOW}/ ¯ + diff --git a/asciiarts/linuxmint.txt b/asciiarts/linuxmint.txt index b03cf24..7c26c13 100644 --- a/asciiarts/linuxmint.txt +++ b/asciiarts/linuxmint.txt @@ -4,3 +4,4 @@ {WHITE}|| {GREEN}| {WHITE}| | {GREEN}| {WHITE} | {GREEN}| {WHITE}---- {GREEN}| {WHITE} --{GREEN}'--------' + diff --git a/asciiarts/macos.txt b/asciiarts/macos.txt index 90d877c..d8e1308 100644 --- a/asciiarts/macos.txt +++ b/asciiarts/macos.txt @@ -5,3 +5,4 @@ {PINK} w w {MAGENTA} w w {BLUE} www_-_www + diff --git a/asciiarts/opensuse-leap.txt b/asciiarts/opensuse-leap.txt index c520c93..57bf9bf 100644 --- a/asciiarts/opensuse-leap.txt +++ b/asciiarts/opensuse-leap.txt @@ -4,3 +4,5 @@ _ / {WHITE}O O{GREEN}\ __. ω / '----' + + diff --git a/asciiarts/opensuse-tumbleweed.txt b/asciiarts/opensuse-tumbleweed.txt index c520c93..57bf9bf 100644 --- a/asciiarts/opensuse-tumbleweed.txt +++ b/asciiarts/opensuse-tumbleweed.txt @@ -4,3 +4,5 @@ _ / {WHITE}O O{GREEN}\ __. ω / '----' + + diff --git a/asciiarts/pop.txt b/asciiarts/pop.txt index 6fd5398..fef44af 100644 --- a/asciiarts/pop.txt +++ b/asciiarts/pop.txt @@ -4,3 +4,4 @@ | {LPINK}~ {WHITE}P! {LPINK}~ {BLUE}| _ ---\ ω / \_/ '-----' + diff --git a/asciiarts/raspbian.txt b/asciiarts/raspbian.txt index 3784f2f..2bec710 100644 --- a/asciiarts/raspbian.txt +++ b/asciiarts/raspbian.txt @@ -4,3 +4,4 @@ (_(_)(_)_) (_(__)_) (__) + diff --git a/asciiarts/slackware.txt b/asciiarts/slackware.txt index 45bbd27..78cd4f5 100644 --- a/asciiarts/slackware.txt +++ b/asciiarts/slackware.txt @@ -5,3 +5,4 @@ | {LPINK}~ {WHITE}S {LPINK}~ {MAGENTA}| _ ---\ ω / \_/ '-----' + diff --git a/asciiarts/solus.txt b/asciiarts/solus.txt index 6ac7e24..8f6b540 100644 --- a/asciiarts/solus.txt +++ b/asciiarts/solus.txt @@ -5,3 +5,4 @@ |{BLUE}_{LPINK}~{BLUE}_____{LPINK}~{WHITE}\| {BLUE}_ ---\ {WHITE}ω {BLUE}/ \_/ '-----' + diff --git a/asciiarts/ubuntu.txt b/asciiarts/ubuntu.txt index 16ffb82..7ed4cb8 100644 --- a/asciiarts/ubuntu.txt +++ b/asciiarts/ubuntu.txt @@ -4,3 +4,4 @@ (_) |>ω<| | \ --- _/ {PINK}C__/{LPINK}---(_) + diff --git a/asciiarts/void.txt b/asciiarts/void.txt index ced389d..56e7b7c 100644 --- a/asciiarts/void.txt +++ b/asciiarts/void.txt @@ -5,3 +5,4 @@ | | {WHITE}ÒωÓ {GREEN}| | , | \_____\_|-, | -_______\ \_/ + diff --git a/asciiarts/windows.txt b/asciiarts/windows.txt deleted file mode 100644 index ee2629e..0000000 --- a/asciiarts/windows.txt +++ /dev/null @@ -1 +0,0 @@ -FUCK YOU \ No newline at end of file diff --git a/asciiarts/xerolinux.txt b/asciiarts/xerolinux.txt index 264e381..b309046 100644 --- a/asciiarts/xerolinux.txt +++ b/asciiarts/xerolinux.txt @@ -5,3 +5,4 @@ ______ / \______ ____/__/__\__\___ / __| |__-\ /_-'' ''-_\ + diff --git a/constants/constants.go b/constants/constants.go deleted file mode 100644 index fabbf85..0000000 --- a/constants/constants.go +++ /dev/null @@ -1,23 +0,0 @@ -package constants - -const Defaultcolor = "red 255 38 116 \ngreen 16 210 117\nblue 104 174 212\nwhite 250 253 255" - -//DO NOT YELL AT ME THAT THIS ISNT A CONST YOU CANT MAKE A CONST YOU FUCKER - -var Color_map = map[string]string{ - "black": "30", - "red": "31", - "green": "32", - "yellow": "33", - "blue": "34", - "magenta": "35", - "cyan": "36", - "white": "37", - "*": "37", -} - -var Namechanges = map[string]string{ - "linux": "linuwu", - "arch": "nyarch", - "ubuntu": "uwuntu", -} diff --git a/data/data.go b/data/data.go index c219466..35192d5 100644 --- a/data/data.go +++ b/data/data.go @@ -2,114 +2,13 @@ package data import ( "fmt" - "net" "os" - "os/exec" - "strconv" "strings" ) -func GetGPU() string { - cmd := exec.Command("lspci", "-v") - shell, err := cmd.Output() - _ = err - var bruh string - 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 -} -func GetLocalIP() string { - addrs, err := net.InterfaceAddrs() - if err != nil { - return "" - } - for _, address := range addrs { - if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() { - if ipnet.IP.To4() != nil { - return ipnet.IP.String() - } - } - } - return "" -} -func GetUsername() string { - cmd := exec.Command("whoami") - shell, _ := cmd.Output() - return strings.Replace(string(shell), "\n", "", -1) -} - -func GetUptime() string { - content, _ := os.ReadFile("/proc/uptime") - return (string(content[0:strings.Index(string(content), ".")])) - -} - -func GetKernel() string { - cmd := exec.Command("uname", "-r") - kernel, err := cmd.Output() - if err != nil { - fmt.Println(err.Error()) - return "fuck you" - } - return string(kernel) -} - -func Unamebs(gamering string) string { - cmd := exec.Command("uname", gamering) - shell, _ := cmd.Output() - return strings.Replace(string(shell), "\n", "", -1) -} - func GetDistro() string { return GetDistroVariable("PRETTY_NAME") } -func GetMemory(used bool) string { - - // - // 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 - if used { - return formatmem(mem_used / 1024) - } else { - return formatmem(mem_total / 1024) - } -} -func GetHome() string { - return os.Getenv("HOME") - -} -func GetConfigFile() string { - return GetHome() + "/.config/neowofetch/conf" -} func GetDistroVariable(varname string) string { distro, err := os.ReadFile("/etc/os-release") if err != nil { @@ -128,58 +27,3 @@ func GetDistroVariable(varname string) string { } return strings.Trim(distro_tuples[varname], "\"") } - -// FormatTime -// I wrote this garbage 2 years ago. I'm too lazy to completely rewrite it. its absolute garbage. im so sorry. -func FormatTime(seconds int) string { - minutes := seconds / 60 - secondsRemaining := strconv.Itoa(seconds % 60) - hour := minutes / 60 - minutesRemaining := strconv.Itoa(minutes % 60) - if hour <= 24 { - return strconv.Itoa(hour) + "h " + minutesRemaining + "m " + secondsRemaining + "s" - } - day := strconv.Itoa(hour / 24) - hourRemaining := strconv.Itoa(hour % 24) - return day + "d " + hourRemaining + "h " + minutesRemaining + "m " + secondsRemaining + "s" -} - -// func GetCPU() { -// mem, _ := os.Open("/proc/cpuinfo") -// memInfo := make([]byte, 1024) -// mem.Read(memInfo) -// mem.Close() -// return (memInfo) -// } -func GetTerminal() string { - a, existprgm := os.LookupEnv("TERM_PROGRAM") - if !existprgm { - return os.Getenv("TERM") - } else { - return a - } - -} -func formatmem(input int) string { - return strconv.Itoa(input) + "MiB" -} -func GetShell() string { - return os.Getenv("SHELL") -} -func GetWM() string { - cmd := exec.Command("wmctrl", "-m") - shell, _ := cmd.Output() - line := strings.Split(string(shell), "\n")[0] - return strings.ReplaceAll(line, "Name: ", "") -} -func getPackages() { -} -func getResolution() { -} - -func getTheme() { -} -func getIcons() { -} -func getColorPalette() { -} diff --git a/main.go b/main.go index 92ef23b..434c614 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "io/ioutil" "os" "os/exec" @@ -14,47 +15,43 @@ import ( var isuwuified bool = true -func checkforconfigfolder() { - _, folder := os.Stat(data.GetHome() + "/.config") - if os.IsNotExist(folder) { - os.Mkdir(data.GetHome()+"/.config", os.ModePerm) - } +func getHome() string { + return os.Getenv("HOME") + } -func getShellVersion(shellCommand string) string { - // https://www.youtube.com/watch?v=YPN0qhSyWy8 - cmd := shellCommand + " --version | grep -o -E \"([0-9]\\.?)*\" | head -n1" - out, _ := exec.Command("bash", "-c", cmd).Output() - return filepath.Base(shellCommand) + " " + strings.ReplaceAll(string(out), "\n", "") +func getConfigFile() string { + return getHome() + "/.config/neowofetch/conf" } func handleConfig() { - _, folder := os.Stat(filepath.Dir(data.GetConfigFile())) - _, file := os.Stat(data.GetConfigFile()) + _, folder := os.Stat(filepath.Dir(getConfigFile())) + _, file := os.Stat(getConfigFile()) if os.IsNotExist(folder) { - os.Mkdir(filepath.Dir(data.GetConfigFile()), os.ModePerm) + os.Mkdir(filepath.Dir(getConfigFile()), os.ModePerm) } - defaultconfig := "println green neOwOfetchh 🔥\ninfo white username\nprint blue @\ninfoln blue hostname\nprint white|space=12 uptime:\ninfoln red uptime\nprint white|space=12 shell:\ninfoln blue shell\nprint white|space=12 distro:\ninfoln blue distro\nprint white|space=12 terminal:\ninfoln blue terminal\nprint white|space=12 WM:\ninfoln blue wm\nprint white|space=12 memory:\ninfo blue memoryUsed\nprint white /\ninfoln blue memoryAll" + if os.IsNotExist(file) { - f, _ := os.Create(data.GetConfigFile()) - _, _ = f.WriteString(defaultconfig) - } - body, _ := ioutil.ReadFile(data.GetConfigFile()) - sbody := (string(body)) - if utils.Defaultconf { - sbody = defaultconfig - } - fbody := strings.Split(sbody, "\n") - for _, line := range fbody { - word := strings.Split(line, " ") - if len(word) < 3 { - continue + println("config was not found. a default config file has been generated in '~/.config/neowofetch/conf'") + f, _ := os.Create(getConfigFile()) + _, _ = f.WriteString("println green neOwOfetch 🔥\ninfo magenta username\nprint blue @\ninfoln blue hostname\nprint white uptime: \ninfoln red uptime\nprint white shell: \ninfoln blue shell\nprint white distro: \ninfoln blue distro\nprint white terminal: \ninfoln blue terminal\nprint white memory: \ninfo blue memoryUsed\nprint white /\ninfoln blue memoryAll") + } else { + body, _ := ioutil.ReadFile(getConfigFile()) + sbody := (string(body)) + fbody := strings.Split(sbody, "\n") + for _, line := range fbody { + word := strings.Split(line, " ") + if len(word) < 3 { + continue + } + action := word[0] + color := word[1] + rest := strings.Join(word[2:], " ") + handlePrint(action, color, rest) } - action := word[0] - color := word[1] - rest := strings.Join(word[2:], " ") - handlePrint(action, color, rest) + } + } func handlePrint(action, format string, rest string) { @@ -64,62 +61,158 @@ func handlePrint(action, format string, rest string) { utils.CutePrint(rest, format) utils.CuteNewLine() } else if action == "info" || action == "infoln" { - infoGetters := map[string]func() string{ - "distro": func() string { - if utils.Asciiforced { - return utils.Forceddistro - } - return data.GetDistro() - }, - "username": data.GetUsername, - "uptime": func() string { - no, _ := strconv.Atoi(data.GetUptime()) - return data.FormatTime(no) - }, - "hostname": func() string { return data.Unamebs("-n") }, - "kernelname": func() string { return data.Unamebs("-srm") }, - //"CPU": data.GetCPU, - "GPU": data.GetGPU, - "shell": func() string { return getShellVersion(data.GetShell()) }, - "terminal": data.GetTerminal, - "memoryAll": func() string { return data.GetMemory(false) }, - "memoryUsed": func() string { return data.GetMemory(true) }, - "wm": data.GetWM, - "ip": data.GetLocalIP, + switch rest { + case "distro": + utils.CutePrint(data.GetDistro(), format) + case "username": + utils.CutePrint(getUsername(), format) + case "uptime": + no, _ := strconv.Atoi(getUptime()) + utils.CutePrint(formatTime(no), format) + case "hostname": + utils.CutePrint(getHostname(), format) + case "GPU": + utils.CutePrint(getGPU(), format) + case "shell": + utils.CutePrint(getShell(), format) + case "terminal": + utils.CutePrint(getTerminal(), format) + case "memoryAll": + utils.CutePrint(getMemory(false), format) + case "memoryUsed": + utils.CutePrint(getMemory(true), format) + default: + print("{UNKNOWN KEYWORD}") } - - getter, ok := infoGetters[rest] - if ok { - utils.CutePrint(getter(), format) - } else { - utils.CutePrint("{UNKNOWN KEYWORD: "+rest+"}", format) - } - if action == "infoln" { utils.CuteNewLine() } } } -func runpage() { - if utils.Ishelp { - println(`neowofetch version x (idk how to implement this) ---nouwu turns off uwuifying ---usepng uses a png (only supports arch and ubuntu rn) ---noascii turns off the ascii ---nocolor no color. ---noconf uses builtin config instead of looking for one in the filesystem ---nocolorconf same thing but for color config :P ---16color uses escape codes instead of RGB ---help YOU LITERALLY FUCKING RAN IT RIGHT NOW`) +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) +} + +func getKernel() string { + cmd := exec.Command("uname", "-r") + kernel, err := cmd.Output() + if err != nil { + fmt.Println(err.Error()) + return "fuck you" + } + return string(kernel) +} +func getUptime() string { + content, _ := os.ReadFile("/proc/uptime") + return (string(content[0:strings.Index(string(content), ".")])) + +} +func getPackages() { +} +func getShell() string { + return os.Getenv("SHELL") +} +func getResolution() { + +} +func getWM() { +} +func getTheme() { +} +func getIcons() { +} +func getTerminal() string { + a, existprgm := os.LookupEnv("TERM_PROGRAM") + if !existprgm { + return os.Getenv("TERM") + } else { + return a + } + +} +func getCPU() { + mem, _ := os.Open("/proc/cpuinfo") + 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) + print(mem_info) +} +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 +} +func getMemory(used bool) string { + + // + // 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) + if used { + return strconv.Itoa(mem_used / 1024) + } else { + return strconv.Itoa(mem_total / 1024) + } +} + +func formatTime(seconds int) string { + minutes := seconds / 60 + secondsre := strconv.Itoa(seconds % 60) + hour := strconv.Itoa(minutes / 60) + minutesre := strconv.Itoa(minutes % 60) + return (hour + "h " + minutesre + "m " + secondsre + "s") +} + +func getColorPalette() { } func main() { utils.Initargs() - runpage() - checkforconfigfolder() utils.Initcolor() utils.CutePrintInit() handleConfig() diff --git a/utils/args.go b/utils/args.go index a6df40f..201a46f 100644 --- a/utils/args.go +++ b/utils/args.go @@ -13,12 +13,8 @@ var usepng bool = false var hascolor bool = true var Customascii = false var asciidir string -var Asciiforced = false -var Forceddistro string -var Defaultconf bool = false -var Defaultcolor bool = false -var colorold bool = false -var Ishelp bool = false +var asciiforced = false +var forceddistro string func Gethn() string { cmd := exec.Command("whoami") @@ -33,8 +29,8 @@ func Initargs() { asciidir = strings.ReplaceAll(argument[8:], "~", "/home/"+Gethn()) } if strings.HasPrefix(argument, "--distro=") { - Asciiforced = true - Forceddistro = argument[9:] + asciiforced = true + forceddistro = argument[9:] } else if strings.HasPrefix(argument, "--") { switch argument { case "--nouwu": @@ -45,18 +41,11 @@ func Initargs() { usepng = true case "--nocolor": hascolor = false - case "--noconf": - Defaultconf = true - case "--nocolorconf": - Defaultcolor = true - case "--16color": - colorold = true - case "--help": - Ishelp = true - default: - print("unknown argument: ", argument, ". please run --help for help\n") - os.Exit(0) } } } } + +func Woulduwuify() bool { + return shoulduwuify +} diff --git a/utils/asciiarts.go b/utils/asciiarts.go new file mode 100644 index 0000000..1f0fd79 --- /dev/null +++ b/utils/asciiarts.go @@ -0,0 +1,128 @@ +package utils + +func Getascii(name string) string { + + switch name { + case "alphine": + return `. .___. + / \/ \ / + /OωO\ɛU\/ __ + / \ \__/ \ +/ \ \` + case "amogos": + return ` ▄▄▄▄▄▄▄ + █ ▄▄▄▄▄ █ + ▐ █▄▄▄█ █ + ▌ ▐ + ▐ ▐ + █ ▐ + ▐ ▐▀▀▀▀█ ▐ + ▐▀▀▀ ▐ ▐ ▐ + ▀▀▀▀▀▀ █▀▀▀ █ + ▀▀▀▀▀▀ ` + case "android": + return ` \ _------_ / + / \ + | ~ > ω < ~ | + ------------ + + + ` + case "arcolinux": + return ` /\ + / \ + / \ + /O vv O\ + / / \ \ + / / __\ \ + /__/ \___\` + case "artix": + return ` /\ + / \ + /''.,\ + /• w • \ + / ,'\ + / ,.''. \ + /.,'' ''.\ + ` + case "debian": + return ` ______ + / ___ \ + | / OωO | + | \____- + -_ + --_\ + + ` + case "endeavouros": + return ` /\ + // \\ + //>ω<\\ + // \ \ + / / _) ) + /_/___-- ___- + /____---` + case "fedora": + return ` _____ + / __)\ + > | / <\ \ + ___| ω|__/ / + / (_ _)_/ + / / | | + \ \__/ | + \(_____/ + ` + case "freebsd": + return ` + /\,-'''''-,/\ + \_) (_/ + | \ / | + | O ω O | + ; ; + '-_____-' + ` + case "gentoo": + return ` _-----_ + ( \\ + \\ OωO \\ + \\ ) + / _/ + ( _- + \\____- + ` + case "guix": + return ` ,= ,-_-. =. + ((_/)U U(\_)) + '-'(. .)'-' + \w/ + ¯` + case "ios": + return ` WHY THE FUCK + ARE YOU USING IOS + PIECE OF FUCKING SHIT` + case "arch": + return ` /\ + / \ + /\ \ + / > ω <\ + / __ \ + / __| |__-\ +/_-'' ''-_\ + ` + case "linuxmint": + return ` /\______/\. + |.--. | + , ¯| | UωU| | +|| | | | | + | | ---- | + --'--------'` + + default: + return `!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!! +!!!!noascii!!!! +!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!! ` + } + +} diff --git a/utils/printing.go b/utils/printing.go index 1c6374b..8bb6dd7 100644 --- a/utils/printing.go +++ b/utils/printing.go @@ -10,7 +10,6 @@ import ( "strings" "github.com/exhq/neowofetch/asciiarts" - "github.com/exhq/neowofetch/constants" "github.com/exhq/neowofetch/data" "github.com/exhq/neowofetch/images" ) @@ -20,7 +19,6 @@ func rgb(r, g, b int) string { } var colors = make(map[string]string) -var oldcolors = make(map[string]int) var logoIndex = 0 var isInProgressLine = false @@ -31,47 +29,39 @@ var pngWidth = 12 var pngHeight = 12 var pngData []byte -var colorconf = os.Getenv("HOME") + "/.config/neowofetch/colors" -var folderconf = filepath.Dir(colorconf) -var _, existcolorconf = os.Stat(colorconf) -var _, existfolderconf = os.Stat(folderconf) - func Initcolor() { + colorconf := os.Getenv("HOME") + "/.config/neowofetch/colors" + folderconf := filepath.Dir(colorconf) + + _, existcolorconf := os.Stat(colorconf) + _, existfolderconf := os.Stat(folderconf) if os.IsNotExist(existfolderconf) { os.Mkdir(folderconf, os.ModePerm) } if os.IsNotExist(existcolorconf) { + println("color was not found. a default config file has been generated in '~/.config/neowofetch/colors'. rerun the program") f, _ := os.Create(colorconf) - _, _ = f.WriteString(constants.Defaultcolor) + _, _ = f.WriteString("red 255 0 0 \nblue 0 255 0\nred 0 0 255\nwhite 255 255 255") + os.Exit(0) } - c, _ := os.ReadFile(colorconf) - content := string(c) - if Defaultcolor { - content = constants.Defaultcolor - } + content, _ := os.ReadFile(colorconf) lines := strings.Split(string(content), "\n") - for _, line := range lines { - if line == "" { - continue - } word := strings.Split(line, " ") - R, _ := strconv.Atoi(word[1]) G, _ := strconv.Atoi(word[2]) B, _ := strconv.Atoi(word[3]) colors[word[0]] = rgb(R, G, B) - } } func CutePrintInit() { dist := data.GetDistroVariable("ID") logo := asciiarts.GetAscii(dist) - if Asciiforced { - logo = asciiarts.GetAscii(Forceddistro) + if asciiforced { + logo = asciiarts.GetAscii(forceddistro) } if noascii { logo = "" @@ -109,30 +99,19 @@ func printLogoIfAtBeginningOfNewLine() { } } -func uwuify(message string) string { +func uwuify(message string) (ret string) { sentence := strings.Split(message, " ") - ret := "" + ret = "" for i, word := range sentence { - word = strings.ToLower(word) + if !strings.Contains(strings.ToLower(word), "uwu") { + word = strings.ReplaceAll(word, "u", "UwU") - if constants.Namechanges[word] != "" { - word = constants.Namechanges[word] - if i != 0 { - ret += " " - } - ret += word - continue - } - - if len(word) > 5 { - if !strings.Contains(word, "owo") { + if strings.Contains(strings.ToLower(word), "owo") { word = strings.ReplaceAll(word, "o", "OwO") - } else if !strings.Contains(word, "uwu") { - word = strings.ReplaceAll(word, "u", "UwU") } - word = strings.ReplaceAll(strings.ReplaceAll(word, "r", "w"), "l", "w") - } + word = strings.ReplaceAll(word, "r", "w") + } if i != 0 { ret += " " } @@ -142,33 +121,26 @@ func uwuify(message string) string { } type Format struct { - spaces int - noUwuOverride bool - colorFormat string - oldcolorFormat int + noUwuOverride bool + colorFormat string } func parseFormat(format string) (parsedFormat Format) { for _, v := range strings.Split(format, "|") { colorFormat, isColor := colors[v] - parsedFormat.colorFormat += colorFormat if isColor && hascolor { parsedFormat.colorFormat += colorFormat } else { - if strings.HasPrefix(v, "space") { - parsedFormat.spaces, _ = strconv.Atoi(v[6:]) - return - } switch v { case "italic": parsedFormat.colorFormat += "\x1b[3m" case "bold": - parsedFormat.colorFormat += "\033[1m" + parsedFormat.colorFormat += "\x1b1" case "nouwu": parsedFormat.noUwuOverride = true case "*": default: - if hascolor && !colorold { + if hascolor { println("Unknown format code: ", v) } } @@ -178,10 +150,10 @@ func parseFormat(format string) (parsedFormat Format) { } func getcustomizeddistro() string { - if !Asciiforced { + if !asciiforced { return data.GetDistroVariable("ID") } else { - return Forceddistro + return forceddistro } } @@ -195,27 +167,7 @@ func CutePrint( if willUwuify { message = uwuify(message) } - neededspaces := parsedFormat.spaces - len(message) - if neededspaces < 0 { - neededspaces = 0 - } - if !colorold { - fmt.Printf("%s%s\x1b[0m%s", parsedFormat.colorFormat, message, strings.Repeat(" ", neededspaces)) - } else { - if os.IsNotExist(existcolorconf) { - f, _ := os.Create(colorconf) - _, _ = f.WriteString("red 255 0 0 \ngreen 0 255 0\nblue 0 0 255\nwhite 255 255 255") - } - if colorold && hascolor { - for k, v := range constants.Color_map { - if strings.Contains(format, k) { - fmt.Printf("\033[1;%sm%s\033[m", v, message) - break - } - } - } - } - + fmt.Printf("%s%s\x1b[0m", parsedFormat.colorFormat, message) } func CuteNewLine() { @@ -229,12 +181,11 @@ func CutePrintEnd() { CuteNewLine() } if usepng { - fmt.Print("\x1b7") fmt.Printf("\x1b[%dA", logoIndex) fmt.Printf("\x1b]1337;File=inline=1;width=%d;height=%d:", pngWidth, pngHeight) enc := base64.NewEncoder(base64.StdEncoding, os.Stdout) enc.Write(images.DistroImages[getcustomizeddistro()]) enc.Close() - fmt.Print("\a\x1b8") + fmt.Println("\a") } }