respect XDG_DATA_HOME
This commit is contained in:
2
main.go
2
main.go
@@ -158,7 +158,7 @@ func main() {
|
|||||||
configDirectory = configDir()
|
configDirectory = configDir()
|
||||||
|
|
||||||
if !pathExists(filepath.Join(configDirectory, "drawer.css")) {
|
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()
|
cacheDirectory := cacheDir()
|
||||||
|
|||||||
11
tools.go
11
tools.go
@@ -202,12 +202,19 @@ func copyFile(src, dst string) error {
|
|||||||
return os.Chmod(dst, srcinfo.Mode())
|
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 {
|
func getAppDirs() []string {
|
||||||
var dirs []string
|
var dirs []string
|
||||||
xdgDataDirs := ""
|
xdgDataDirs := ""
|
||||||
|
|
||||||
home := os.Getenv("HOME")
|
home := os.Getenv("HOME")
|
||||||
xdgDataHome := os.Getenv("XDG_DATA_HOME")
|
xdgDataHome := getDataHome()
|
||||||
if os.Getenv("XDG_DATA_DIRS") != "" {
|
if os.Getenv("XDG_DATA_DIRS") != "" {
|
||||||
xdgDataDirs = os.Getenv("XDG_DATA_DIRS")
|
xdgDataDirs = os.Getenv("XDG_DATA_DIRS")
|
||||||
} else {
|
} else {
|
||||||
@@ -257,7 +264,7 @@ func listDesktopFiles() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setUpCategories() {
|
func setUpCategories() {
|
||||||
path := "/usr/share/nwg-menu/desktop-directories"
|
path := filepath.Join(getDataHome(), "nwg-menu/desktop-directories")
|
||||||
var other category
|
var other category
|
||||||
|
|
||||||
for _, cName := range categoryNames {
|
for _, cName := range categoryNames {
|
||||||
|
|||||||
Reference in New Issue
Block a user