diff options
-rw-r--r-- | config.go | 19 | ||||
-rw-r--r-- | main.go | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/config.go b/config.go new file mode 100644 index 0000000..21f0406 --- /dev/null +++ b/config.go @@ -0,0 +1,19 @@ +package main + +import ( + "os" + "path/filepath" + + "github.com/goulash/xdg" +) + +func MaybeWriteConfig() { + path := xdg.FindConfig("timetasker/config.toml") + + if path == "" { + path = filepath.Join(xdg.ConfigHome, "timetasker") + if _, err := os.Stat(path); os.IsNotExist(err) { + os.Mkdir(path, 0700) + } + } +} @@ -29,6 +29,7 @@ var config Config func main() { var err error + MaybeWriteConfig() loadConfig() // Parse command line arguments |