-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support XDG Base Directory #31
Comments
Is it ok to support it using environmental variables in order to keep backward compatibility ?
So in case of pomo it would be
|
Currently the default configuration for pomo looks like this: {
"colors": null,
"dateTimeFmt": "2006-01-02 15:04",
"basePath": "/home/kevin/.pomo",
"dbPath": "/home/kevin/.pomo/pomo.db",
"socketPath": "/home/kevin/.pomo/pomo.sock",
"iconPath": "/home/kevin/.pomo/icon.png"
} Where
Regarding backward compatibility I'm fine with just adding some documentation instructing users to move their sqlite file into the new default path. There is some relevant discussion in golang/go#29960 but I'm not entirely sure what the right solution is for non-linux systems. package main
import (
"fmt"
"os"
"os/user"
"path"
)
func getConfigPath() string {
basepath, err := os.UserConfigDir()
if err != nil {
panic(err)
}
return path.Join(basepath, ".pomo/config.json")
}
func getDataDir() string {
basepath := os.Getenv("XDG_DATA_HOME")
if basepath == "" {
user, _ := user.Current()
return path.Join(user.HomeDir, ".local/share/pomo")
}
return path.Join(basepath, "pomo")
}
func getSocketPath() string {
basepath := os.Getenv("XDG_RUNTIME_DIR")
if basepath == "" {
user, _ := user.Current()
// BUG: What to do on OSX/Windows?
return path.Join("/run/user", user.Uid, "pomo.socket")
}
return path.Join(basepath, "pomo.socket")
}
func main() {
fmt.Println(getConfigPath())
fmt.Println(getDataDir())
fmt.Println(getSocketPath())
}
|
Implemented with #58 |
Pomo should support the XDG Base Directory specification and not default to polluting the home directory with
~/.pomo
.The text was updated successfully, but these errors were encountered: