mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-16 07:56:12 +00:00
Rewrite 'GetDistroAsciiArt' function
This commit is contained in:
+22
-26
@@ -65,39 +65,35 @@ func GetDistroAsciiArt() string {
|
||||
(| | )
|
||||
/'\_ _/'\
|
||||
\___)=(___/ `
|
||||
var id string
|
||||
if config.Ascii == "auto" {
|
||||
id = GetDistroInfo().ID
|
||||
|
||||
// Get ascii name to use
|
||||
var asciiName string
|
||||
if Ascii != "" {
|
||||
asciiName = Ascii
|
||||
} else if config.Ascii == "auto" {
|
||||
asciiName = GetDistroInfo().ID
|
||||
} else {
|
||||
id = config.Ascii
|
||||
asciiName = config.Ascii
|
||||
}
|
||||
|
||||
// Check for ascii art in home directory
|
||||
userConfDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
if _, err := os.Stat(path.Join(SystemConfigDir, "stormfetch/ascii/", id)); err == nil {
|
||||
bytes, err := os.ReadFile(path.Join(SystemConfigDir, "stormfetch/ascii/", id))
|
||||
if err != nil {
|
||||
return defaultAscii
|
||||
if err == nil {
|
||||
if _, err := os.Stat(path.Join(userConfDir, "stormfetch/ascii/", asciiName)); err == nil {
|
||||
if bytes, err := os.ReadFile(path.Join(userConfDir, "stormfetch/ascii/", asciiName)); err == nil {
|
||||
return string(bytes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for ascii art in system config directory
|
||||
if _, err := os.Stat(path.Join(SystemConfigDir, "stormfetch/ascii/", asciiName)); err == nil {
|
||||
if bytes, err := os.ReadFile(path.Join(SystemConfigDir, "stormfetch/ascii/", asciiName)); err == nil {
|
||||
return string(bytes)
|
||||
} else {
|
||||
return defaultAscii
|
||||
}
|
||||
}
|
||||
if _, err := os.Stat(path.Join(userConfDir, "stormfetch/ascii/", id)); err == nil {
|
||||
bytes, err := os.ReadFile(path.Join(userConfDir, "stormfetch/ascii/", id))
|
||||
if err != nil {
|
||||
return defaultAscii
|
||||
}
|
||||
return string(bytes)
|
||||
} else if _, err := os.Stat(path.Join(SystemConfigDir, "stormfetch/ascii/", id)); err == nil {
|
||||
bytes, err := os.ReadFile(path.Join(SystemConfigDir, "stormfetch/ascii/", id))
|
||||
if err != nil {
|
||||
return defaultAscii
|
||||
}
|
||||
return strings.TrimRight(string(bytes), "\n\t ")
|
||||
} else {
|
||||
return defaultAscii
|
||||
}
|
||||
|
||||
return defaultAscii
|
||||
}
|
||||
|
||||
func GetArch() string {
|
||||
|
||||
Reference in New Issue
Block a user