fix for absolute paths
This commit is contained in:
parent
584d2dcd78
commit
c9c617a1f0
20
main.go
20
main.go
@ -7,6 +7,7 @@ import (
|
||||
_ "image/png"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -44,7 +45,7 @@ func getDist() string {
|
||||
return dist
|
||||
}
|
||||
}
|
||||
return "unknown distro :("
|
||||
return "no /etc/os-release file found"
|
||||
}
|
||||
|
||||
func getRam() string {
|
||||
@ -199,6 +200,19 @@ func printLogo(path string, width uint) {
|
||||
}
|
||||
}
|
||||
|
||||
func getAbsLogoPath(relativePath string) string {
|
||||
if _, err := os.Stat(relativePath); err == nil {
|
||||
return relativePath
|
||||
}
|
||||
|
||||
systemPath := filepath.Join("/usr/share/gogofetch", relativePath)
|
||||
if _, err := os.Stat(systemPath); err == nil {
|
||||
return systemPath
|
||||
}
|
||||
|
||||
return relativePath
|
||||
}
|
||||
|
||||
func main() {
|
||||
type Info struct {
|
||||
Label string
|
||||
@ -210,6 +224,8 @@ func main() {
|
||||
defaultLogo = logoMap["default"]
|
||||
}
|
||||
|
||||
absoluteDefaultLogo := getAbsLogoPath(defaultLogo)
|
||||
|
||||
stats := []Info{
|
||||
{"dist", dist},
|
||||
{"host", getHostname()},
|
||||
@ -220,7 +236,7 @@ func main() {
|
||||
{"pkgs", getPkgs()},
|
||||
}
|
||||
|
||||
logoPath := flag.String("l", defaultLogo, "Absolute or relative path to the logo image")
|
||||
logoPath := flag.String("l", absoluteDefaultLogo, "Absolute or relative path to the logo image")
|
||||
width := flag.Int("w", 200, "Logo width in lines")
|
||||
flag.Parse()
|
||||
if _, err := os.Stat(*logoPath); os.IsNotExist(err) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user