mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
doctor: use builtin config/cache dir functions
This commit is contained in:
@@ -577,12 +577,16 @@ func checkOptionalDependencies() []checkResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkConfigurationFiles() []checkResult {
|
func checkConfigurationFiles() []checkResult {
|
||||||
|
configDir, _ := os.UserConfigDir()
|
||||||
|
cacheDir, _ := os.UserCacheDir()
|
||||||
|
dmsDir := "DankMaterialShell"
|
||||||
|
|
||||||
configFiles := []struct{ name, path string }{
|
configFiles := []struct{ name, path string }{
|
||||||
{"settings.json", filepath.Join(utils.XDGConfigHome(), "DankMaterialShell", "settings.json")},
|
{"settings.json", filepath.Join(configDir, dmsDir, "settings.json")},
|
||||||
{"clsettings.json", filepath.Join(utils.XDGConfigHome(), "DankMaterialShell", "clsettings.json")},
|
{"clsettings.json", filepath.Join(configDir, dmsDir, "clsettings.json")},
|
||||||
{"plugin_settings.json", filepath.Join(utils.XDGConfigHome(), "DankMaterialShell", "plugin_settings.json")},
|
{"plugin_settings.json", filepath.Join(configDir, dmsDir, "plugin_settings.json")},
|
||||||
{"session.json", filepath.Join(utils.XDGStateHome(), "DankMaterialShell", "session.json")},
|
{"session.json", filepath.Join(utils.XDGStateHome(), dmsDir, "session.json")},
|
||||||
{"dms-colors.json", filepath.Join(utils.XDGCacheHome(), "DankMaterialShell", "dms-colors.json")},
|
{"dms-colors.json", filepath.Join(cacheDir, dmsDir, "dms-colors.json")},
|
||||||
}
|
}
|
||||||
|
|
||||||
var results []checkResult
|
var results []checkResult
|
||||||
|
|||||||
@@ -29,5 +29,5 @@ func IsServiceActive(name string, userService bool) bool {
|
|||||||
args = []string{"--user", "is-active", name}
|
args = []string{"--user", "is-active", name}
|
||||||
}
|
}
|
||||||
output, _ := exec.Command("systemctl", args...).Output()
|
output, _ := exec.Command("systemctl", args...).Output()
|
||||||
return strings.TrimSpace(string(output)) == "active"
|
return strings.EqualFold(strings.TrimSpace(string(output)), "active")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,28 +6,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func xdgDir(envVar string, defaultPath ...string) string {
|
func XDGStateHome() string {
|
||||||
if dir := os.Getenv(envVar); dir != "" {
|
if dir := os.Getenv("XDG_STATE_HOME"); dir != "" {
|
||||||
return dir
|
return dir
|
||||||
}
|
}
|
||||||
|
|
||||||
home, _ := os.UserHomeDir()
|
home, _ := os.UserHomeDir()
|
||||||
return filepath.Join(append([]string{home}, defaultPath...)...)
|
return filepath.Join(append([]string{home}, ".local", "state")...)
|
||||||
}
|
|
||||||
|
|
||||||
func XDGConfigHome() string {
|
|
||||||
return xdgDir("XDG_CONFIG_HOME", ".config")
|
|
||||||
}
|
|
||||||
|
|
||||||
func XDGStateHome() string {
|
|
||||||
return xdgDir("XDG_STATE_HOME", ".local", "state")
|
|
||||||
}
|
|
||||||
|
|
||||||
func XDGCacheHome() string {
|
|
||||||
return xdgDir("XDG_CACHE_HOME", ".cache")
|
|
||||||
}
|
|
||||||
|
|
||||||
func XDGDataHome() string {
|
|
||||||
return xdgDir("XDG_DATA_HOME", ".local", "share")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExpandPath(path string) (string, error) {
|
func ExpandPath(path string) (string, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user