mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
doctor: indicate if config files are readonly
This commit is contained in:
@@ -539,15 +539,26 @@ func checkOptionalDependencies() []checkResult {
|
|||||||
|
|
||||||
func checkConfigurationFiles() []checkResult {
|
func checkConfigurationFiles() []checkResult {
|
||||||
configFiles := []struct{ name, path string }{
|
configFiles := []struct{ name, path string }{
|
||||||
{"Settings", filepath.Join(utils.XDGConfigHome(), "DankMaterialShell", "settings.json")},
|
{"settings.json", filepath.Join(utils.XDGConfigHome(), "DankMaterialShell", "settings.json")},
|
||||||
{"Session", filepath.Join(utils.XDGStateHome(), "DankMaterialShell", "session.json")},
|
{"clsettings.json", filepath.Join(utils.XDGConfigHome(), "DankMaterialShell", "clsettings.json")},
|
||||||
{"Colors", filepath.Join(utils.XDGCacheHome(), "DankMaterialShell", "dms-colors.json")},
|
{"plugin_settings.json", filepath.Join(utils.XDGConfigHome(), "DankMaterialShell", "plugin_settings.json")},
|
||||||
|
{"session.json", filepath.Join(utils.XDGStateHome(), "DankMaterialShell", "session.json")},
|
||||||
|
{"dms-colors.json", filepath.Join(utils.XDGCacheHome(), "DankMaterialShell", "dms-colors.json")},
|
||||||
}
|
}
|
||||||
|
|
||||||
results := []checkResult{}
|
results := []checkResult{}
|
||||||
for _, cf := range configFiles {
|
for _, cf := range configFiles {
|
||||||
if _, err := os.Stat(cf.path); err == nil {
|
info, err := os.Stat(cf.path)
|
||||||
results = append(results, checkResult{catConfigFiles, cf.name, "ok", "Present", cf.path})
|
if err == nil {
|
||||||
|
status := "ok"
|
||||||
|
message := "Present"
|
||||||
|
|
||||||
|
if info.Mode().Perm()&0200 == 0 {
|
||||||
|
status = "warn"
|
||||||
|
message += " (read-only)"
|
||||||
|
}
|
||||||
|
|
||||||
|
results = append(results, checkResult{catConfigFiles, cf.name, status, message, cf.path})
|
||||||
} else {
|
} else {
|
||||||
results = append(results, checkResult{catConfigFiles, cf.name, "info", "Not yet created", cf.path})
|
results = append(results, checkResult{catConfigFiles, cf.name, "info", "Not yet created", cf.path})
|
||||||
}
|
}
|
||||||
@@ -651,11 +662,14 @@ func printResultLine(r checkResult, styles tui.Styles) {
|
|||||||
|
|
||||||
name := r.name
|
name := r.name
|
||||||
nameLen := len(name)
|
nameLen := len(name)
|
||||||
if nameLen > 18 {
|
|
||||||
name = name[:17] + "…"
|
maxLength := 21
|
||||||
nameLen = 18
|
|
||||||
|
if nameLen > maxLength {
|
||||||
|
name = name[:maxLength-1] + "…"
|
||||||
|
nameLen = maxLength
|
||||||
}
|
}
|
||||||
dots := strings.Repeat("·", 19-nameLen)
|
dots := strings.Repeat("·", maxLength-nameLen)
|
||||||
|
|
||||||
fmt.Printf(" %s %s %s %s\n", style.Render(icon), name, styles.Subtle.Render(dots), r.message)
|
fmt.Printf(" %s %s %s %s\n", style.Render(icon), name, styles.Subtle.Render(dots), r.message)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user