use XDG_CONFIG_HOME if set

This commit is contained in:
Gokcehan 2016-09-02 23:04:26 +03:00
parent 188bd97b3b
commit 66482b8495

17
main.go
View File

@ -11,11 +11,12 @@ import (
) )
var ( var (
envUser = os.Getenv("USER") envUser = os.Getenv("USER")
envHome = os.Getenv("HOME") envHome = os.Getenv("HOME")
envHost = os.Getenv("HOSTNAME") envHost = os.Getenv("HOSTNAME")
envPath = os.Getenv("PATH") envPath = os.Getenv("PATH")
envShell = os.Getenv("SHELL") envShell = os.Getenv("SHELL")
envConfig = os.Getenv("XDG_CONFIG_HOME")
) )
var ( var (
@ -42,6 +43,9 @@ func init() {
} }
envHost = host envHost = host
} }
if envConfig == "" {
envConfig = path.Join(envHome, ".config")
}
tmp := os.TempDir() tmp := os.TempDir()
@ -51,8 +55,7 @@ func init() {
gLogPath = path.Join(tmp, fmt.Sprintf("lf.%s.log", envUser)) gLogPath = path.Join(tmp, fmt.Sprintf("lf.%s.log", envUser))
gServerLogPath = path.Join(tmp, fmt.Sprintf("lf.%s.server.log", envUser)) gServerLogPath = path.Join(tmp, fmt.Sprintf("lf.%s.server.log", envUser))
// TODO: xdg-config-home etc. gConfigPath = path.Join(envConfig, "lf", "lfrc")
gConfigPath = path.Join(envHome, ".config", "lf", "lfrc")
} }
func startServer() { func startServer() {