1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-27 06:52:50 -05:00

doctor: use builtin config/cache dir functions

This commit is contained in:
LuckShiba
2026-01-03 18:53:15 -03:00
parent 002039bd3f
commit 13c352fd58
3 changed files with 14 additions and 25 deletions

View File

@@ -29,5 +29,5 @@ func IsServiceActive(name string, userService bool) bool {
args = []string{"--user", "is-active", name}
}
output, _ := exec.Command("systemctl", args...).Output()
return strings.TrimSpace(string(output)) == "active"
return strings.EqualFold(strings.TrimSpace(string(output)), "active")
}

View File

@@ -6,28 +6,13 @@ import (
"strings"
)
func xdgDir(envVar string, defaultPath ...string) string {
if dir := os.Getenv(envVar); dir != "" {
func XDGStateHome() string {
if dir := os.Getenv("XDG_STATE_HOME"); dir != "" {
return dir
}
home, _ := os.UserHomeDir()
return filepath.Join(append([]string{home}, defaultPath...)...)
}
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")
return filepath.Join(append([]string{home}, ".local", "state")...)
}
func ExpandPath(path string) (string, error) {