summaryrefslogtreecommitdiffstats
path: root/utils/xdg.go
blob: 84890428155dc1e277b404ce9dbb0eb84d2f4485 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package utils

import (
	"os"
	"path/filepath"
)

func GetConfigDir(name string) string {
	var basedir string
	if env := os.Getenv("XDG_CONFIG_HOME"); env != "" {
		basedir = env
	} else {
		basedir = filepath.Join(os.Getenv("HOME"), ".config")
	}
	return filepath.Join(basedir, name)
}

func GetLogDir(name string) string {
	var basedir string
	if env := os.Getenv("XDG_STATE_HOME"); env != "" {
		basedir = env
	} else {
		basedir = filepath.Join(os.Getenv("HOME"), ".local", "state")
	}
	return filepath.Join(basedir, name)
}