1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Clean up the code in cfg/ a bit

This commit is contained in:
Chris Cummer 2018-08-03 05:31:31 -07:00
parent 0cfdd93502
commit 1f27cf5b00
2 changed files with 9 additions and 5 deletions

View File

@ -10,16 +10,19 @@ import (
"github.com/senorprogrammer/wtf/wtf"
)
const CONFIG_DIR_V1 = "~/.wtf/"
const CONFIG_DIR_V2 = "~/.config/wtf/"
// ConfigDirV1 defines the path to the first version of configuration. Do not use this
const ConfigDirV1 = "~/.wtf/"
// ConfigDirV2 defines the path to the second version of the configuration. Use this.
const ConfigDirV2 = "~/.config/wtf/"
/* -------------------- Config Migration -------------------- */
// MigrateOldConfig copies any existing configuration from the old location
// to the new, XDG-compatible location
func MigrateOldConfig() {
srcDir, _ := wtf.ExpandHomeDir(CONFIG_DIR_V1)
destDir, _ := wtf.ExpandHomeDir(CONFIG_DIR_V2)
srcDir, _ := wtf.ExpandHomeDir(ConfigDirV1)
destDir, _ := wtf.ExpandHomeDir(ConfigDirV2)
// If the old config directory doesn't exist, do not move
if _, err := os.Stat(srcDir); os.IsNotExist(err) {
@ -52,7 +55,7 @@ func MigrateOldConfig() {
// ConfigDir returns the absolute path to the configuration directory
func ConfigDir() (string, error) {
configDir, err := wtf.ExpandHomeDir(CONFIG_DIR_V2)
configDir, err := wtf.ExpandHomeDir(ConfigDirV2)
if err != nil {
return "", err
}

View File

@ -53,6 +53,7 @@ import (
var focusTracker wtf.FocusTracker
var widgets []wtf.Wtfable
// Config parses the config.yml file and makes available the settings within
var Config *config.Config
var (