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:
parent
0cfdd93502
commit
1f27cf5b00
@ -10,16 +10,19 @@ import (
|
|||||||
"github.com/senorprogrammer/wtf/wtf"
|
"github.com/senorprogrammer/wtf/wtf"
|
||||||
)
|
)
|
||||||
|
|
||||||
const CONFIG_DIR_V1 = "~/.wtf/"
|
// ConfigDirV1 defines the path to the first version of configuration. Do not use this
|
||||||
const CONFIG_DIR_V2 = "~/.config/wtf/"
|
const ConfigDirV1 = "~/.wtf/"
|
||||||
|
|
||||||
|
// ConfigDirV2 defines the path to the second version of the configuration. Use this.
|
||||||
|
const ConfigDirV2 = "~/.config/wtf/"
|
||||||
|
|
||||||
/* -------------------- Config Migration -------------------- */
|
/* -------------------- Config Migration -------------------- */
|
||||||
|
|
||||||
// MigrateOldConfig copies any existing configuration from the old location
|
// MigrateOldConfig copies any existing configuration from the old location
|
||||||
// to the new, XDG-compatible location
|
// to the new, XDG-compatible location
|
||||||
func MigrateOldConfig() {
|
func MigrateOldConfig() {
|
||||||
srcDir, _ := wtf.ExpandHomeDir(CONFIG_DIR_V1)
|
srcDir, _ := wtf.ExpandHomeDir(ConfigDirV1)
|
||||||
destDir, _ := wtf.ExpandHomeDir(CONFIG_DIR_V2)
|
destDir, _ := wtf.ExpandHomeDir(ConfigDirV2)
|
||||||
|
|
||||||
// If the old config directory doesn't exist, do not move
|
// If the old config directory doesn't exist, do not move
|
||||||
if _, err := os.Stat(srcDir); os.IsNotExist(err) {
|
if _, err := os.Stat(srcDir); os.IsNotExist(err) {
|
||||||
@ -52,7 +55,7 @@ func MigrateOldConfig() {
|
|||||||
|
|
||||||
// ConfigDir returns the absolute path to the configuration directory
|
// ConfigDir returns the absolute path to the configuration directory
|
||||||
func ConfigDir() (string, error) {
|
func ConfigDir() (string, error) {
|
||||||
configDir, err := wtf.ExpandHomeDir(CONFIG_DIR_V2)
|
configDir, err := wtf.ExpandHomeDir(ConfigDirV2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
1
main.go
1
main.go
@ -53,6 +53,7 @@ import (
|
|||||||
var focusTracker wtf.FocusTracker
|
var focusTracker wtf.FocusTracker
|
||||||
var widgets []wtf.Wtfable
|
var widgets []wtf.Wtfable
|
||||||
|
|
||||||
|
// Config parses the config.yml file and makes available the settings within
|
||||||
var Config *config.Config
|
var Config *config.Config
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user