imagine neofetch, but OwO -
+
@@ -17,8 +13,48 @@ 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.
diff --git a/asciiarts/alpine.txt b/asciiarts/alpine.txt index 41409b6..3520e07 100644 --- a/asciiarts/alpine.txt +++ b/asciiarts/alpine.txt @@ -4,5 +4,3 @@ /OωO\ɛU\/ __ / \ \__/ \ / \ \ - - diff --git a/asciiarts/amog.txt b/asciiarts/amog.txt new file mode 100644 index 0000000..ab0d48b --- /dev/null +++ b/asciiarts/amog.txt @@ -0,0 +1,4 @@ + ┌──┐ +┌┤ █▋ +└┤┌┐│ + └┘└┘ \ No newline at end of file diff --git a/asciiarts/android.txt b/asciiarts/android.txt index 6045cfc..2ac1afb 100644 --- a/asciiarts/android.txt +++ b/asciiarts/android.txt @@ -3,6 +3,3 @@ / \ | {RED}~ {GREEN}> ω < {RED}~ {GREEN}| ------------ - - - diff --git a/asciiarts/arch.txt b/asciiarts/arch.txt index d4e77f8..2055997 100644 --- a/asciiarts/arch.txt +++ b/asciiarts/arch.txt @@ -5,4 +5,3 @@ / __ \ / __| |__-\ /_-'' ''-_\ - diff --git a/asciiarts/archcraft.txt b/asciiarts/archcraft.txt new file mode 100644 index 0000000..2055997 --- /dev/null +++ b/asciiarts/archcraft.txt @@ -0,0 +1,7 @@ +{BLUE} /\ + / \ + /\ \ + / > ω <\ + / __ \ + / __| |__-\ + /_-'' ''-_\ diff --git a/asciiarts/arcolinux.txt b/asciiarts/arcolinux.txt index 307c35e..9992c67 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 b76e9df..d66b419 100644 --- a/asciiarts/asciiart.go +++ b/asciiarts/asciiart.go @@ -1,28 +1,20 @@ package asciiarts import ( - _ "embed" - "strings" + "embed" + "regexp" ) -//go:embed alpine.txt -var Alpine string +//go:embed *.txt +var asciifiles embed.FS -//go:embed unknown.txt -var unknown string - -func GetAsciiInternal(distroID string) string { - switch distroID { - case "Alpine": - return Alpine - default: - return unknown - } -} func GetAscii(distroID string) string { - ascii := GetAsciiInternal(distroID) - ascii = strings.ReplaceAll(ascii, "{WHITE}", "") - ascii = strings.ReplaceAll(ascii, "{YELLOW}", "") - ascii = strings.ReplaceAll(ascii, "{BLUE}", "") + regex, _ := regexp.Compile("{[[:upper:]]+}") + asciiBuff, error := asciifiles.ReadFile(distroID + ".txt") + if error != nil { + asciiBuff, _ = asciifiles.ReadFile("unknown.txt") + } + ascii := string(asciiBuff) + ascii = regex.ReplaceAllString(ascii, "") return ascii } diff --git a/asciiarts/debian.txt b/asciiarts/debian.txt index 54a85ea..daa40bf 100644 --- a/asciiarts/debian.txt +++ b/asciiarts/debian.txt @@ -4,5 +4,3 @@ | \____- -_ --_\ - - \ No newline at end of file diff --git a/asciiarts/freebsd.txt b/asciiarts/freebsd.txt index 3b44a43..995ac84 100644 --- a/asciiarts/freebsd.txt +++ b/asciiarts/freebsd.txt @@ -5,4 +5,3 @@ | O ω O | ; ; '-_____-' - diff --git a/asciiarts/gentoo.txt b/asciiarts/gentoo.txt index 7924ef4..d18587e 100644 --- a/asciiarts/gentoo.txt +++ b/asciiarts/gentoo.txt @@ -5,4 +5,3 @@ / _/ ( _- \\____- - diff --git a/asciiarts/gnu.txt b/asciiarts/gnu.txt index eea2a71..d09a222 100644 --- a/asciiarts/gnu.txt +++ b/asciiarts/gnu.txt @@ -5,4 +5,3 @@ `-'{YELLOW}(. .){WHITE}`-' {YELLOW}\{WHITE}w{YELLOW}/ ¯ - diff --git a/asciiarts/guix.txt b/asciiarts/guix.txt index eea2a71..d09a222 100644 --- a/asciiarts/guix.txt +++ b/asciiarts/guix.txt @@ -5,4 +5,3 @@ `-'{YELLOW}(. .){WHITE}`-' {YELLOW}\{WHITE}w{YELLOW}/ ¯ - diff --git a/asciiarts/linuxmint.txt b/asciiarts/linuxmint.txt index 7c26c13..b03cf24 100644 --- a/asciiarts/linuxmint.txt +++ b/asciiarts/linuxmint.txt @@ -4,4 +4,3 @@ {WHITE}|| {GREEN}| {WHITE}| | {GREEN}| {WHITE} | {GREEN}| {WHITE}---- {GREEN}| {WHITE} --{GREEN}'--------' - diff --git a/asciiarts/macos.txt b/asciiarts/macos.txt index d8e1308..90d877c 100644 --- a/asciiarts/macos.txt +++ b/asciiarts/macos.txt @@ -5,4 +5,3 @@ {PINK} w w {MAGENTA} w w {BLUE} www_-_www - diff --git a/asciiarts/opensuse-leap.txt b/asciiarts/opensuse-leap.txt index 57bf9bf..c520c93 100644 --- a/asciiarts/opensuse-leap.txt +++ b/asciiarts/opensuse-leap.txt @@ -4,5 +4,3 @@ _ / {WHITE}O O{GREEN}\ __. ω / '----' - - diff --git a/asciiarts/opensuse-tumbleweed.txt b/asciiarts/opensuse-tumbleweed.txt index 57bf9bf..c520c93 100644 --- a/asciiarts/opensuse-tumbleweed.txt +++ b/asciiarts/opensuse-tumbleweed.txt @@ -4,5 +4,3 @@ _ / {WHITE}O O{GREEN}\ __. ω / '----' - - diff --git a/asciiarts/pop.txt b/asciiarts/pop.txt index fef44af..6fd5398 100644 --- a/asciiarts/pop.txt +++ b/asciiarts/pop.txt @@ -4,4 +4,3 @@ | {LPINK}~ {WHITE}P! {LPINK}~ {BLUE}| _ ---\ ω / \_/ '-----' - diff --git a/asciiarts/raspbian.txt b/asciiarts/raspbian.txt index 2bec710..3784f2f 100644 --- a/asciiarts/raspbian.txt +++ b/asciiarts/raspbian.txt @@ -4,4 +4,3 @@ (_(_)(_)_) (_(__)_) (__) - diff --git a/asciiarts/slackware.txt b/asciiarts/slackware.txt index 78cd4f5..45bbd27 100644 --- a/asciiarts/slackware.txt +++ b/asciiarts/slackware.txt @@ -5,4 +5,3 @@ | {LPINK}~ {WHITE}S {LPINK}~ {MAGENTA}| _ ---\ ω / \_/ '-----' - diff --git a/asciiarts/solus.txt b/asciiarts/solus.txt index 8f6b540..6ac7e24 100644 --- a/asciiarts/solus.txt +++ b/asciiarts/solus.txt @@ -5,4 +5,3 @@ |{BLUE}_{LPINK}~{BLUE}_____{LPINK}~{WHITE}\| {BLUE}_ ---\ {WHITE}ω {BLUE}/ \_/ '-----' - diff --git a/asciiarts/ubuntu.txt b/asciiarts/ubuntu.txt index 7ed4cb8..16ffb82 100644 --- a/asciiarts/ubuntu.txt +++ b/asciiarts/ubuntu.txt @@ -4,4 +4,3 @@ (_) |>ω<| | \ --- _/ {PINK}C__/{LPINK}---(_) - diff --git a/asciiarts/void.txt b/asciiarts/void.txt index 56e7b7c..ced389d 100644 --- a/asciiarts/void.txt +++ b/asciiarts/void.txt @@ -5,4 +5,3 @@ | | {WHITE}ÒωÓ {GREEN}| | , | \_____\_|-, | -_______\ \_/ - diff --git a/asciiarts/windows.txt b/asciiarts/windows.txt new file mode 100644 index 0000000..ee2629e --- /dev/null +++ b/asciiarts/windows.txt @@ -0,0 +1 @@ +FUCK YOU \ No newline at end of file diff --git a/asciiarts/xerolinux.txt b/asciiarts/xerolinux.txt index b309046..264e381 100644 --- a/asciiarts/xerolinux.txt +++ b/asciiarts/xerolinux.txt @@ -5,4 +5,3 @@ ______ / \______ ____/__/__\__\___ / __| |__-\ /_-'' ''-_\ - diff --git a/constants/constants.go b/constants/constants.go new file mode 100644 index 0000000..fabbf85 --- /dev/null +++ b/constants/constants.go @@ -0,0 +1,23 @@ +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 35192d5..c219466 100644 --- a/data/data.go +++ b/data/data.go @@ -2,13 +2,114 @@ 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 { @@ -27,3 +128,58 @@ 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 434c614..92ef23b 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "io/ioutil" "os" "os/exec" @@ -15,43 +14,47 @@ import ( var isuwuified bool = true -func getHome() string { - return os.Getenv("HOME") - +func checkforconfigfolder() { + _, folder := os.Stat(data.GetHome() + "/.config") + if os.IsNotExist(folder) { + os.Mkdir(data.GetHome()+"/.config", os.ModePerm) + } } -func getConfigFile() string { - return getHome() + "/.config/neowofetch/conf" +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 handleConfig() { - _, folder := os.Stat(filepath.Dir(getConfigFile())) - _, file := os.Stat(getConfigFile()) + _, folder := os.Stat(filepath.Dir(data.GetConfigFile())) + _, file := os.Stat(data.GetConfigFile()) if os.IsNotExist(folder) { - os.Mkdir(filepath.Dir(getConfigFile()), os.ModePerm) + os.Mkdir(filepath.Dir(data.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) { - 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) - } - + 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 + } + action := word[0] + color := word[1] + rest := strings.Join(word[2:], " ") + handlePrint(action, color, rest) } - } func handlePrint(action, format string, rest string) { @@ -61,158 +64,62 @@ func handlePrint(action, format string, rest string) { utils.CutePrint(rest, format) utils.CuteNewLine() } else if action == "info" || action == "infoln" { - 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}") + 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, } + + getter, ok := infoGetters[rest] + if ok { + utils.CutePrint(getter(), format) + } else { + utils.CutePrint("{UNKNOWN KEYWORD: "+rest+"}", format) + } + if action == "infoln" { utils.CuteNewLine() } } } -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()) +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`) 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 201a46f..a6df40f 100644 --- a/utils/args.go +++ b/utils/args.go @@ -13,8 +13,12 @@ var usepng bool = false var hascolor bool = true var Customascii = false var asciidir string -var asciiforced = false -var forceddistro string +var Asciiforced = false +var Forceddistro string +var Defaultconf bool = false +var Defaultcolor bool = false +var colorold bool = false +var Ishelp bool = false func Gethn() string { cmd := exec.Command("whoami") @@ -29,8 +33,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": @@ -41,11 +45,18 @@ 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 deleted file mode 100644 index 1f0fd79..0000000 --- a/utils/asciiarts.go +++ /dev/null @@ -1,128 +0,0 @@ -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 8bb6dd7..1c6374b 100644 --- a/utils/printing.go +++ b/utils/printing.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/exhq/neowofetch/asciiarts" + "github.com/exhq/neowofetch/constants" "github.com/exhq/neowofetch/data" "github.com/exhq/neowofetch/images" ) @@ -19,6 +20,7 @@ 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 @@ -29,39 +31,47 @@ var pngWidth = 12 var pngHeight = 12 var pngData []byte -func Initcolor() { - colorconf := os.Getenv("HOME") + "/.config/neowofetch/colors" - folderconf := filepath.Dir(colorconf) +var colorconf = os.Getenv("HOME") + "/.config/neowofetch/colors" +var folderconf = filepath.Dir(colorconf) +var _, existcolorconf = os.Stat(colorconf) +var _, existfolderconf = os.Stat(folderconf) - _, existcolorconf := os.Stat(colorconf) - _, existfolderconf := os.Stat(folderconf) +func Initcolor() { 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("red 255 0 0 \nblue 0 255 0\nred 0 0 255\nwhite 255 255 255") - os.Exit(0) + _, _ = f.WriteString(constants.Defaultcolor) } - content, _ := os.ReadFile(colorconf) + c, _ := os.ReadFile(colorconf) + content := string(c) + if Defaultcolor { + content = constants.Defaultcolor + } 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 = "" @@ -99,19 +109,30 @@ func printLogoIfAtBeginningOfNewLine() { } } -func uwuify(message string) (ret string) { +func uwuify(message string) string { sentence := strings.Split(message, " ") - ret = "" + ret := "" for i, word := range sentence { - if !strings.Contains(strings.ToLower(word), "uwu") { - word = strings.ReplaceAll(word, "u", "UwU") + word = strings.ToLower(word) - if strings.Contains(strings.ToLower(word), "owo") { - word = strings.ReplaceAll(word, "o", "OwO") + if constants.Namechanges[word] != "" { + word = constants.Namechanges[word] + if i != 0 { + ret += " " } - word = strings.ReplaceAll(word, "r", "w") - + ret += word + continue } + + if len(word) > 5 { + if !strings.Contains(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") + } + if i != 0 { ret += " " } @@ -121,26 +142,33 @@ func uwuify(message string) (ret string) { } type Format struct { - noUwuOverride bool - colorFormat string + spaces int + noUwuOverride bool + colorFormat string + oldcolorFormat int } 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 += "\x1b1" + parsedFormat.colorFormat += "\033[1m" case "nouwu": parsedFormat.noUwuOverride = true case "*": default: - if hascolor { + if hascolor && !colorold { println("Unknown format code: ", v) } } @@ -150,10 +178,10 @@ func parseFormat(format string) (parsedFormat Format) { } func getcustomizeddistro() string { - if !asciiforced { + if !Asciiforced { return data.GetDistroVariable("ID") } else { - return forceddistro + return Forceddistro } } @@ -167,7 +195,27 @@ func CutePrint( if willUwuify { message = uwuify(message) } - fmt.Printf("%s%s\x1b[0m", parsedFormat.colorFormat, 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 + } + } + } + } + } func CuteNewLine() { @@ -181,11 +229,12 @@ 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.Println("\a") + fmt.Print("\a\x1b8") } }