ok you win
This commit is contained in:
parent
c9a1908276
commit
67c52b7be4
2 changed files with 37 additions and 49 deletions
43
main.go
43
main.go
|
@ -13,8 +13,8 @@ import (
|
|||
|
||||
var isuwuified bool = true
|
||||
|
||||
func checkforconfigfolder(){
|
||||
_, folder := os.Stat(data.GetHome()+"/.config")
|
||||
func checkforconfigfolder() {
|
||||
_, folder := os.Stat(data.GetHome() + "/.config")
|
||||
if os.IsNotExist(folder) {
|
||||
os.Mkdir(data.GetHome()+"/.config", os.ModePerm)
|
||||
}
|
||||
|
@ -28,30 +28,25 @@ func handleConfig() {
|
|||
}
|
||||
defaultconfig := "println green neOwOfetchh 🔥\ninfo white 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"
|
||||
if os.IsNotExist(file) {
|
||||
println("config was not found. a default config file has been generated in '~/.config/neowofetch/conf'. rerun the program")
|
||||
f, _ := os.Create(data.GetConfigFile())
|
||||
_, _ = f.WriteString(defaultconfig)
|
||||
os.Exit(0)
|
||||
} else {
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -91,7 +86,7 @@ func handlePrint(action, format string, rest string) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
checkforconfigfolder()
|
||||
checkforconfigfolder()
|
||||
utils.Initargs()
|
||||
utils.Initcolor()
|
||||
utils.CutePrintInit()
|
||||
|
|
|
@ -20,6 +20,17 @@ func rgb(r, g, b int) string {
|
|||
|
||||
var colors = make(map[string]string)
|
||||
var oldcolors = make(map[string]int)
|
||||
var color_map = map[string]string{
|
||||
"black": "30",
|
||||
"red": "31",
|
||||
"green": "32",
|
||||
"yellow": "33",
|
||||
"blue": "34",
|
||||
"magenta": "35",
|
||||
"cyan": "36",
|
||||
"white": "37",
|
||||
"*": "37",
|
||||
}
|
||||
|
||||
var logoIndex = 0
|
||||
var isInProgressLine = false
|
||||
|
@ -41,10 +52,8 @@ func Initcolor() {
|
|||
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 \ngreen 0 255 0\nblue 0 0 255\nwhite 255 255 255")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
c, _ := os.ReadFile(colorconf)
|
||||
|
@ -184,31 +193,15 @@ func CutePrint(
|
|||
fmt.Printf("%s%s\x1b[0m", parsedFormat.colorFormat, message)
|
||||
} else {
|
||||
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 \ngreen 0 255 0\nblue 0 0 255\nwhite 255 255 255")
|
||||
os.Exit(0)
|
||||
} else if colorold && hascolor {
|
||||
switch {
|
||||
case strings.Contains(format, "black"):
|
||||
fmt.Printf("\033[1;30m%s\033[0m", message)
|
||||
case strings.Contains(format, "red"):
|
||||
fmt.Printf("\033[1;31m%s\033[0m", message)
|
||||
case strings.Contains(format, "green"):
|
||||
fmt.Printf("\033[1;32m%s\033[0m", message)
|
||||
case strings.Contains(format, "yellow"):
|
||||
fmt.Printf("\033[1;33m%s\033[0m", message)
|
||||
case strings.Contains(format, "blue"):
|
||||
fmt.Printf("\033[1;34m%s\033[0m", message)
|
||||
case strings.Contains(format, "magenta"):
|
||||
fmt.Printf("\033[1;35m%s\033[0m", message)
|
||||
case strings.Contains(format, "cyan"):
|
||||
fmt.Printf("\033[1;36m%s\033[0m", message)
|
||||
case strings.Contains(format, "white"):
|
||||
fmt.Printf("\033[1;37m%s\033[0m", message)
|
||||
case strings.Contains(format, "*"):
|
||||
fmt.Printf("\033[1;37m%s\033[0m", message)
|
||||
|
||||
}
|
||||
if colorold && hascolor {
|
||||
for k, v := range color_map {
|
||||
if strings.Contains(format, k) {
|
||||
fmt.Printf("\033[1;%sm%s\033[m", v, message)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue