respect XDG_DATA_HOME

This commit is contained in:
piotr
2021-06-18 01:56:47 +02:00
parent 6f40068253
commit 24295dfd76
2 changed files with 10 additions and 3 deletions

View File

@@ -158,7 +158,7 @@ func main() {
configDirectory = configDir()
if !pathExists(filepath.Join(configDirectory, "drawer.css")) {
copyFile("/usr/share/nwg-drawer/drawer.css", filepath.Join(configDirectory, "drawer.css"))
copyFile(filepath.Join(getDataHome(), "nwg-drawer/drawer.css"), filepath.Join(configDirectory, "drawer.css"))
}
cacheDirectory := cacheDir()

View File

@@ -202,12 +202,19 @@ func copyFile(src, dst string) error {
return os.Chmod(dst, srcinfo.Mode())
}
func getDataHome() string {
if os.Getenv("XDG_DATA_HOME") != "" {
return os.Getenv("XDG_DATA_HOME")
}
return "/usr/share/"
}
func getAppDirs() []string {
var dirs []string
xdgDataDirs := ""
home := os.Getenv("HOME")
xdgDataHome := os.Getenv("XDG_DATA_HOME")
xdgDataHome := getDataHome()
if os.Getenv("XDG_DATA_DIRS") != "" {
xdgDataDirs = os.Getenv("XDG_DATA_DIRS")
} else {
@@ -257,7 +264,7 @@ func listDesktopFiles() []string {
}
func setUpCategories() {
path := "/usr/share/nwg-menu/desktop-directories"
path := filepath.Join(getDataHome(), "nwg-menu/desktop-directories")
var other category
for _, cName := range categoryNames {