Skip to content

Commit

Permalink
Clean up the code in cfg/ a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Cummer committed Aug 3, 2018
1 parent 0cfdd93 commit 1f27cf5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cfg/config_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 1f27cf5

Please sign in to comment.