Added missing dependency warning
This commit is contained in:
parent
200e300be0
commit
2b33b64602
@ -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
|
||||
```
|
||||
|
@ -1,2 +1,3 @@
|
||||
distro_ascii: auto
|
||||
fetch_script: auto
|
||||
dependency_warning: true
|
18
main.go
18
main.go
@ -18,6 +18,7 @@ var config = StormfetchConfig{}
|
||||
type StormfetchConfig struct {
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user