~f4814n/frost

ref: 7c0d7579bbae138623265ccc19620874855e9135 frost/appdirs/appdirs_linux.go -rw-r--r-- 644 bytes
7c0d7579Fabian Geiselhart Add room information to EphemeralEvent 1 year, 17 days ago
                                                                                
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
27
28
29
30
31
32
package appdirs

import (
	"os"
	"fmt"
)

func getenv(key, def string) (ret string) {
	if val, ok := os.LookupEnv(key); ok {
		ret = val
	} else {
		ret = def
	}

	if ret[0] == '~' {
		return os.Getenv("HOME") + ret[1:]
	}

	return ret
}

func UserDataDir(appname, appauthor string) string {
	return fmt.Sprintf("%s/%s", getenv("XDG_DATA_HOME", "~/.local/share"), appname)
}

func UserCacheDir(appname, appauthor string) string {
	return fmt.Sprintf("%s/%s", getenv("XDG_CACHE_HOME", "~/.cache"), appname)
}

func UserConfigDir(appname, appauthor string) string {
	return fmt.Sprintf("%s/%s", getenv("XDG_CONFIG_HOME", "~/.config"), appname)
}