From 454098514eb3fd0d6edb03270021546420ddc55d Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Sat, 22 Dec 2018 18:40:28 -0800 Subject: [PATCH] Fix config path location on Windows and OSX Config path was $XDG_CONFIG_HOME/gotop on all platforms, but the config path specification is different on Windows and OSX --- go.mod | 1 + go.sum | 10 ++-------- main.go | 10 ++++------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 3d992b4..67edbc5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,7 @@ module github.com/cjbassi/gotop require ( + github.com/ProtonMail/go-appdir v0.0.0-20180220133335-7c788d1b45c6 github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect github.com/cjbassi/drawille-go v0.0.0-20180329221028-ad535d0f92cd // indirect github.com/cjbassi/termui v0.0.0-20181208033036-e8dd23f6146c diff --git a/go.sum b/go.sum index 5810619..a50556f 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,9 @@ +github.com/ProtonMail/go-appdir v0.0.0-20180220133335-7c788d1b45c6 h1:de/SvQsi6Oou9TJYp6Kp17S+JjXGn1w8XVYWFlE0z/U= +github.com/ProtonMail/go-appdir v0.0.0-20180220133335-7c788d1b45c6/go.mod h1:3d8Y9F5mbEUjrYbcJ3rcDxcWbqbttF+011nVZmdRdzc= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/cjbassi/drawille-go v0.0.0-20180329221028-ad535d0f92cd h1:nSJpATLVvFa19BEHX4ys+VGNWfI4FUGMweEI6QXs8wg= github.com/cjbassi/drawille-go v0.0.0-20180329221028-ad535d0f92cd/go.mod h1:vjcQJUZJYD3MeVGhtZXSMnCHfUNZxsyYzJt90eCYxK4= -github.com/cjbassi/termui v0.0.0-20180823181054-5edfcb3a441f h1:t8d9FIPBeDHClPJBkB8yJyIBcMIxzdMAY2xB1vWHi48= -github.com/cjbassi/termui v0.0.0-20180823181054-5edfcb3a441f/go.mod h1:rqXckrwz+i0fH/zNwU6AdBNULHwmZsgehnSlhKP5i2Q= -github.com/cjbassi/termui v0.0.0-20181129202454-e08bceac6d82 h1:Nohf7C2tEJfEtfJ2mAF244MPJUj6JT9Quzf4ZrkmEfE= -github.com/cjbassi/termui v0.0.0-20181129202454-e08bceac6d82/go.mod h1:rqXckrwz+i0fH/zNwU6AdBNULHwmZsgehnSlhKP5i2Q= -github.com/cjbassi/termui v0.0.0-20181129231847-3a3db079d9dd h1:12/9RCEyFB4mnNlafhySzhfPgFIfTxbjHrkhEX0SgDQ= -github.com/cjbassi/termui v0.0.0-20181129231847-3a3db079d9dd/go.mod h1:rqXckrwz+i0fH/zNwU6AdBNULHwmZsgehnSlhKP5i2Q= github.com/cjbassi/termui v0.0.0-20181208033036-e8dd23f6146c h1:vcaCtK8ObawtpQRW8GdbKZ+eJGEUn41xJ8Snagd/c6I= github.com/cjbassi/termui v0.0.0-20181208033036-e8dd23f6146c/go.mod h1:rqXckrwz+i0fH/zNwU6AdBNULHwmZsgehnSlhKP5i2Q= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -22,8 +18,6 @@ github.com/nsf/termbox-go v0.0.0-20180407224525-3e24a7b6661e h1:w2JDz0jtOlFFdvtU github.com/nsf/termbox-go v0.0.0-20180407224525-3e24a7b6661e/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/shirou/gopsutil v0.0.0-20180811135056-68ff0e299699 h1:AJW3z3AIDXJBKlPs1bhA0pb0rYKyTv+rzHE/spMC72Y= -github.com/shirou/gopsutil v0.0.0-20180811135056-68ff0e299699/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v2.18.11+incompatible h1:PMFTKnFTr/YTRW5rbLK4vWALV3a+IGXse5nvhSjztmg= github.com/shirou/gopsutil v2.18.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U= diff --git a/main.go b/main.go index 0a95887..f8e1dc3 100644 --- a/main.go +++ b/main.go @@ -14,11 +14,12 @@ import ( "syscall" "time" + appdir "github.com/ProtonMail/go-appdir" "github.com/cjbassi/gotop/colorschemes" "github.com/cjbassi/gotop/src/logging" w "github.com/cjbassi/gotop/src/widgets" ui "github.com/cjbassi/termui" - "github.com/docopt/docopt-go" + docopt "github.com/docopt/docopt-go" ) var version = "1.7.1" @@ -121,11 +122,8 @@ func handleColorscheme(cs string) error { } func getConfigDir() string { - globalConfigDir := os.Getenv("XDG_CONFIG_HOME") - if globalConfigDir == "" { - globalConfigDir = filepath.Join(os.ExpandEnv("$HOME"), ".config") - } - return filepath.Join(globalConfigDir, "gotop") + dirs := appdir.New("gotop") + return dirs.UserConfig() } // getCustomColorscheme tries to read a custom json colorscheme from {configDir}/{name}.json