1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-05-12 07:19:41 -04:00

screenshot: respect XDG_PICTURES_DIR

fixes #2383
This commit is contained in:
bbedward
2026-05-11 10:00:21 -04:00
parent b192b5f779
commit 676219bc09
3 changed files with 38 additions and 39 deletions

View File

@@ -38,6 +38,36 @@ func XDGConfigHome() string {
return filepath.Join(home, ".config")
}
func XDGPicturesDir() string {
if dir := os.Getenv("XDG_PICTURES_DIR"); dir != "" {
if expanded, err := ExpandPath(dir); err == nil {
return expanded
}
}
data, err := os.ReadFile(filepath.Join(XDGConfigHome(), "user-dirs.dirs"))
if err != nil {
return ""
}
const prefix = "XDG_PICTURES_DIR="
for line := range strings.SplitSeq(string(data), "\n") {
if len(line) == 0 || line[0] == '#' {
continue
}
if !strings.HasPrefix(line, prefix) {
continue
}
path := strings.Trim(line[len(prefix):], "\"")
expanded, err := ExpandPath(path)
if err != nil {
return ""
}
return expanded
}
return ""
}
func EmacsConfigDir() string {
home, _ := os.UserHomeDir()