Added missing dependency warning

This commit is contained in:
CapCreeperGR 2024-05-08 14:26:01 +03:00
parent 200e300be0
commit 2b33b64602
3 changed files with 22 additions and 2 deletions

View File

@ -13,6 +13,7 @@ Stormfetch is still in beta and distro compatibility is limited. If you would li
- Download `go` from your package manager or from the go website
- Download `make` from your package manager
- (Optional) Download `xorg-xhost` from your package manager to display DE/WM and monitor information
- (Optional) Download `xorg-xdpyinfo` from your package manager to display Screen Resolution
- (Optional) Download `lshw` from your package manager to display GPU information
- Run the following command to compile the project
```

View File

@ -1,2 +1,3 @@
distro_ascii: auto
fetch_script: auto
dependency_warning: true

22
main.go
View File

@ -16,8 +16,9 @@ var fetchScriptPath = ""
var config = StormfetchConfig{}
type StormfetchConfig struct {
Ascii string `yaml:"distro_ascii"`
FetchScript string `yaml:"fetch_script"`
Ascii string `yaml:"distro_ascii"`
FetchScript string `yaml:"fetch_script"`
DependencyWarning bool `yaml:"dependency_warning"`
}
type DistroInfo struct {
@ -67,6 +68,23 @@ func readConfig() {
} else {
log.Fatalf("Fetch script file not found: %s", err.Error())
}
// Show Dependency warning if enabled
if config.DependencyWarning {
dependencies := []string{"lshw", "xhost", "xdpyinfo"}
var missing []string
for _, depend := range dependencies {
if _, err := os.Stat(path.Join("/usr/bin/", depend)); err != nil {
missing = append(missing, depend)
}
}
if len(missing) != 0 {
fmt.Println("[WARNING] Stormfetch functionality may be limited due to the following dependencies not being installed:")
for _, depend := range missing {
fmt.Println(depend)
}
fmt.Println("You can disable this warning through your stormfetch config")
}
}
//Execute fetch script
cmd := exec.Command("/bin/bash", fetchScriptPath)
cmd.Dir = path.Dir(fetchScriptPath)