summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2019-02-16 02:11:05 -0800
committerCaleb Bassi <calebjbassi@gmail.com>2019-02-22 11:52:02 -0800
commit334f08bc5ae225c3f3b9ec01c143d135b83f3a5b (patch)
treec4a88d77b53bb1ea85406d53325b5c43efab9886
parent357ff01fe3d387ae6d28dc3eab6b11a49ab58eae (diff)
Revert back to using XDG on macOS
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md5
-rw-r--r--CHANGELOG.md1
-rw-r--r--README.md2
-rw-r--r--go.mod1
-rw-r--r--go.sum2
-rw-r--r--main.go26
-rw-r--r--vendor/github.com/ProtonMail/go-appdir/.gitignore24
-rw-r--r--vendor/github.com/ProtonMail/go-appdir/LICENSE21
-rw-r--r--vendor/github.com/ProtonMail/go-appdir/README.md52
-rw-r--r--vendor/github.com/ProtonMail/go-appdir/appdir.go17
-rw-r--r--vendor/github.com/ProtonMail/go-appdir/appdir_darwin.go22
-rw-r--r--vendor/github.com/ProtonMail/go-appdir/appdir_windows.go22
-rw-r--r--vendor/github.com/ProtonMail/go-appdir/appdir_xdg.go39
-rw-r--r--vendor/github.com/ProtonMail/go-appdir/main.go32
-rw-r--r--vendor/modules.txt2
15 files changed, 26 insertions, 242 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index ab7eb8f..6c1ca65 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -14,7 +14,4 @@ Required information:
- Any relevenat hardware info:
- tmux version if using tmux:
-Also please copy or attach the following file if it exists and contains logs:
-
-- Linux: `~/.local/state/gotop/errors.log`
-- OSX: `~/Library/Logs/gotop/errors.log`
+Also please copy or attach `~/.local/state/gotop/errors.log` if it exists and contains logs:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c48b2f6..992f526 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Change `-v` cli option to `-V` for version
+- Revert back to using the XDG spec on macOS
### Fixed
diff --git a/README.md b/README.md
index 00ba501..92bacab 100644
--- a/README.md
+++ b/README.md
@@ -85,7 +85,7 @@ brew install gotop
gotop ships with a few colorschemes which can be set with the `-c` flag followed by the name of one. You can find all the colorschemes in the [colorschemes folder](./colorschemes).
-To make a custom colorscheme, check out the [template](./colorschemes/template.go) for instructions and then use [default.json](./colorschemes/default.json) as a starter. Then put the file at `~/.config/gotop/<name>.json` on Linux or `~/Library/Application Support/gotop/<name>.json` on OSX and load it with `gotop -c <name>`. Colorschemes PR's are welcome!
+To make a custom colorscheme, check out the [template](./colorschemes/template.go) for instructions and then use [default.json](./colorschemes/default.json) as a starter. Then put the file at `~/.config/gotop/<name>.json` and load it with `gotop -c <name>`. Colorschemes PR's are welcome!
### CLI Options
diff --git a/go.mod b/go.mod
index fb9a123..74c00c2 100644
--- a/go.mod
+++ b/go.mod
@@ -1,7 +1,6 @@
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/battery v0.0.0-20190206091651-451cd0de3f6f
github.com/davecgh/go-spew v1.1.1 // indirect
diff --git a/go.sum b/go.sum
index ca9dc2a..bf091ea 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,3 @@
-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/battery v0.0.0-20190206091651-451cd0de3f6f h1:XtDkrKpWZomFY5YY7vjj/n024Ei/cpLrnrKvXrHI+2s=
diff --git a/main.go b/main.go
index 17bece8..cfc5d19 100644
--- a/main.go
+++ b/main.go
@@ -14,7 +14,6 @@ import (
"syscall"
"time"
- appdir "github.com/ProtonMail/go-appdir"
docopt "github.com/docopt/docopt.go"
ui "github.com/gizak/termui"
@@ -24,14 +23,15 @@ import (
)
const (
+ appName = "gotop"
version = "2.0.2"
graphHorizontalScaleDelta = 3
)
var (
- configDir = appdir.New("gotop").UserConfig()
- logDir = appdir.New("gotop").UserLogs()
+ configDir = getConfigDir(appName)
+ logDir = getLogDir(appName)
logPath = filepath.Join(logDir, "errors.log")
stderrLogger = log.New(os.Stderr, "", 0)
@@ -62,6 +62,26 @@ var (
bar *w.StatusBar
)
+func getConfigDir(name string) string {
+ var basedir string
+ if env := os.Getenv("XDG_CONFIG_HOME"); env != "" {
+ basedir = env
+ } else {
+ basedir = filepath.Join(os.Getenv("HOME"), ".config")
+ }
+ return filepath.Join(basedir, name)
+}
+
+func getLogDir(name string) string {
+ var basedir string
+ if env := os.Getenv("XDG_STATE_HOME"); env != "" {
+ basedir = env
+ } else {
+ basedir = filepath.Join(os.Getenv("HOME"), ".local", "state")
+ }
+ return filepath.Join(basedir, name)
+}
+
func parseArgs() error {
usage := `
Usage: gotop [options]
diff --git a/vendor/github.com/ProtonMail/go-appdir/.gitignore b/vendor/github.com/ProtonMail/go-appdir/.gitignore
deleted file mode 100644
index daf913b..0000000
--- a/vendor/github.com/ProtonMail/go-appdir/.gitignore
+++ /dev/null
@@ -1,24 +0,0 @@
-# Compiled Object files, Static and Dynamic libs (Shared Objects)
-*.o
-*.a
-*.so
-
-# Folders
-_obj
-_test
-
-# Architecture specific extensions/prefixes
-*.[568vq]
-[568vq].out
-
-*.cgo1.go
-*.cgo2.c
-_cgo_defun.c
-_cgo_gotypes.go
-_cgo_export.*
-
-_testmain.go
-
-*.exe
-*.test
-*.prof
diff --git a/vendor/github.com/ProtonMail/go-appdir/LICENSE b/vendor/github.com/ProtonMail/go-appdir/LICENSE
deleted file mode 100644
index 853b46d..0000000
--- a/vendor/github.com/ProtonMail/go-appdir/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2016
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/vendor/github.com/ProtonMail/go-appdir/README.md b/vendor/github.com/ProtonMail/go-appdir/README.md
deleted file mode 100644
index 1479d3c..0000000
--- a/vendor/github.com/ProtonMail/go-appdir/README.md
+++ /dev/null
@@ -1,52 +0,0 @@
-# go-appdir
-
-[![GoDoc](https://godoc.org/github.com/ProtonMail/go-appdir?status.svg)](https://godoc.org/github.com/ProtonMail/go-appdir)
-
-Minimalistic Go package to get application directories such as config and cache.
-
-Platform | Windows | [Linux/BSDs](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) | macOS
--------- | ------- | ------------------------------------------------------------------------------------------ | -----
-User-specific config | `%APPDATA%` (`C:\Users\%USERNAME%\AppData\Roaming`) | `$XDG_CONFIG_HOME` (`$HOME/.config`) | `$HOME/Library/Application Support`
-User-specific cache | `%LOCALAPPDATA%` (`C:\Users\%USERNAME%\AppData\Local`) | `$XDG_CACHE_HOME` (`$HOME/.cache`) | `$HOME/Library/Caches`
-User-specific logs | `%LOCALAPPDATA%` (`C:\Users\%USERNAME%\AppData\Local`) | `$XDG_STATE_HOME` (`$HOME/.local/state`) | `$HOME/Library/Logs`
-
-Inspired by [`configdir`](https://github.com/shibukawa/configdir).
-
-## Usage
-
-```go
-package main
-
-import (
- "os"
- "path/filepath"
-
- "github.com/ProtonMail/go-appdir"
-)
-
-func main() {
- // Get directories for our app
- dirs := appdir.New("my-awesome-app")
-
- // Get user-specific config dir
- p := dirs.UserConfig()
-
- // Create our app config dir
- if err := os.MkdirAll(p, 0755); err != nil {
- panic(err)
- }
-
- // Now we can use it
- f, err := os.Create(filepath.Join(p, "config-file"))
- if err != nil {
- panic(err)
- }
- defer f.Close()
-
- f.Write([]byte("<3"))
-}
-```
-
-## License
-
-MIT
diff --git a/vendor/github.com/ProtonMail/go-appdir/appdir.go b/vendor/github.com/ProtonMail/go-appdir/appdir.go
deleted file mode 100644
index f259e2c..0000000
--- a/vendor/github.com/ProtonMail/go-appdir/appdir.go
+++ /dev/null
@@ -1,17 +0,0 @@
-// Get application directories such as config and cache.
-package appdir
-
-// Dirs requests application directories paths.
-type Dirs interface {
- // Get the user-specific config directory.
- UserConfig() string
- // Get the user-specific cache directory.
- UserCache() string
- // Get the user-specific logs directory.
- UserLogs() string
-}
-
-// New creates a new App with the provided name.
-func New(name string) Dirs {
- return &dirs{name: name}
-}
diff --git a/vendor/github.com/ProtonMail/go-appdir/appdir_darwin.go b/vendor/github.com/ProtonMail/go-appdir/appdir_darwin.go
deleted file mode 100644
index d2043ee..0000000
--- a/vendor/github.com/ProtonMail/go-appdir/appdir_darwin.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package appdir
-
-import (
- "os"
- "path/filepath"
-)
-
-type dirs struct {
- name string
-}
-
-func (d *dirs) UserConfig() string {
- return filepath.Join(os.Getenv("HOME"), "Library", "Application Support", d.name)
-}
-
-func (d *dirs) UserCache() string {
- return filepath.Join(os.Getenv("HOME"), "Library", "Caches", d.name)
-}
-
-func (d *dirs) UserLogs() string {
- return filepath.Join(os.Getenv("HOME"), "Library", "Logs", d.name)
-}
diff --git a/vendor/github.com/ProtonMail/go-appdir/appdir_windows.go b/vendor/github.com/ProtonMail/go-appdir/appdir_windows.go
deleted file mode 100644
index 8be907e..0000000
--- a/vendor/github.com/ProtonMail/go-appdir/appdir_windows.go
+++ /dev/null
@@ -1,22 +0,0 @@
-package appdir
-
-import (
- "os"
- "path/filepath"
-)
-
-type dirs struct {
- name string
-}
-
-func (d *dirs) UserConfig() string {
- return filepath.Join(os.Getenv("APPDATA"), d.name)
-}
-
-func (d *dirs) UserCache() string {
- return filepath.Join(os.Getenv("LOCALAPPDATA"), d.name)
-}
-
-func (d *dirs) UserLogs() string {
- return filepath.Join(os.Getenv("LOCALAPPDATA"), d.name)
-}
diff --git a/vendor/github.com/ProtonMail/go-appdir/appdir_xdg.go b/vendor/github.com/ProtonMail/go-appdir/appdir_xdg.go
deleted file mode 100644
index 8bbc543..0000000
--- a/vendor/github.com/ProtonMail/go-appdir/appdir_xdg.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// +build !darwin,!windows
-
-package appdir
-
-import (
- "os"
- "path/filepath"
-)
-
-type dirs struct {
- name string
-}
-
-func (d *dirs) UserConfig() string {
- baseDir := filepath.Join(os.Getenv("HOME"), ".config")
- if os.Getenv("XDG_CONFIG_HOME") != "" {
- baseDir = os.Getenv("XDG_CONFIG_HOME")
- }
-
- return filepath.Join(baseDir, d.name)
-}
-
-func (d *dirs) UserCache() string {
- baseDir := filepath.Join(os.Getenv("HOME"), ".cache")
- if os.Getenv("XDG_CACHE_HOME") != "" {
- baseDir = os.Getenv("XDG_CACHE_HOME")
- }
-
- return filepath.Join(baseDir, d.name)
-}
-
-func (d *dirs) UserLogs() string {
- baseDir := filepath.Join(os.Getenv("HOME"), ".local", "state")
- if os.Getenv("XDG_STATE_HOME") != "" {
- baseDir = os.Getenv("XDG_STATE_HOME")
- }
-
- return filepath.Join(baseDir, d.name)
-}
diff --git a/vendor/github.com/ProtonMail/go-appdir/main.go b/vendor/github.com/ProtonMail/go-appdir/main.go
deleted file mode 100644
index c9c0fe5..0000000
--- a/vendor/github.com/ProtonMail/go-appdir/main.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// +build ignore
-
-package main
-
-import (
- "os"
- "path/filepath"
-
- "github.com/ProtonMail/go-appdir"
-)
-
-func main() {
- // Get directories for our app
- dirs := appdir.New("my-awesome-app")
-
- // Get user-specific config dir
- p := dirs.UserConfig()
-
- // Create our app config dir
- if err := os.MkdirAll(p, 0755); err != nil {
- panic(err)
- }
-
- // Now we can use it
- f, err := os.Create(filepath.Join(p, "config-file"))
- if err != nil {
- panic(err)
- }
- defer f.Close()
-
- f.Write([]byte("<3"))
-}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 3a9b78c..b848bcd 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -1,5 +1,3 @@
-# github.com/ProtonMail/go-appdir v0.0.0-20180220133335-7c788d1b45c6
-github.com/ProtonMail/go-appdir
# github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6
github.com/StackExchange/wmi
# github.com/cjbassi/battery v0.0.0-20190206091651-451cd0de3f6f