summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md30
-rw-r--r--README.md63
-rw-r--r--cmd/gotop/main.go193
-rw-r--r--colorschemes/registry.go33
-rw-r--r--config.go28
-rw-r--r--docs/releasing.md20
-rw-r--r--go.mod1
-rw-r--r--go.sum2
-rw-r--r--logging/logging.go14
-rw-r--r--widgets/batterygauge.go1
10 files changed, 242 insertions, 143 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index df6bc06..d854f55 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,15 +13,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
> - **Fixed**: for any bug fixes.
> - **Security**: in case of vulnerabilities.
-## [3.5.1] - ??
+## PENDING (NOT RELEASED 3.6)
+
+### Added
+
+- Adds support for system-wide configurations. This improves support for package maintainers.
+- Help function to print key bindings
+- Help prints locations of config files (color schemes & layouts)
+- Help prints location of logs
+
+### Changed
+
+- Log files stored in \$XDG_CACHE_HOME; DATA, CONFIG, CACHE, and RUNTIME are the only directories specified by the FreeDesktop spec.
+- Extensions are now built with a build tool; this is an interim solution until issues with the Go plugin API are resolved.
+
+### Removed
+
+- configdir, logdir, and logfile options in the config file are no longer used. gotop looks for a configuration file, layouts, and colorschemes in the following order: command-line; `pwd`; user-home, and finally a system-wide path. The paths depend on the OS and whether XDG is in use.
+
+## [3.5.1] - 2020-04-09
+
+This is a bug fix release.
### Fixed
-- Removes verbose debugging unintentionally left in the code (#85, #86)
+- Removes verbose debugging unintentionally left in the code (#85)
- kitchensink referenced by, but not included in binary is now included (#72)
- Safety check prevents uninitialized colorscheme registry use
- Updates instructions on where to put colorschemes and layouts (#75)
-- Don't silently succeed when plugins are requested but not found (#77)
+- Trying to use a non-installed plugin should fail, not silently continue (#77)
+
+### Changed
+
+- Improved documentation about installing layouts and colorschemes
## [3.5.0] - 2020-03-06
diff --git a/README.md b/README.md
index ffdbe56..31e31ea 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
Another terminal based graphical activity monitor, inspired by [gtop](https://github.com/aksakalli/gtop) and [vtop](https://github.com/MrRio/vtop), this time written in [Go](https://golang.org/)!
-The original author of gotop has re-implemented the application in Rust, as [ytop](https://github.com/cjbassi/ytop). This is a fork of original gotop project with a new maintainer.
+Join us in [\#gotop:matrix.org](https://riot.im/app/#/room/#gotop:matrix.org) ([matrix clients](https://matrix.to/#/#gotop:matrix.org)).
<img src="./assets/screenshots/demo.gif" />
<img src="./assets/screenshots/kitchensink.gif" />
@@ -21,10 +21,7 @@ The original author of gotop has re-implemented the application in Rust, as [yto
Working and tested on Linux, FreeBSD and MacOS. Windows binaries are provided, but have limited testing. OpenBSD works with some caveats; cross-compiling is difficult and binaries are not provided.
-If you install gotop by hand, or you download or create new layouts or colorschemes, you will need to put the layout files where gotop can find them. This is in one of two places, searched in this order:
-
-1. The current working directory
-2. `${XDG_CONFIG_HOME}/gotop`
+If you install gotop by hand, or you download or create new layouts or colorschemes, you will need to put the layout files where gotop can find them. To see the list of directories gotop looks for files, run `gotop -h`. The first directory is always the directory from which gotop is run.
### Arch
@@ -40,6 +37,15 @@ There is also a build-from-source package:
yay -S gotop
```
+### Gentoo
+
+`gotop` is available on [guru](https://gitweb.gentoo.org/repo/proj/guru.git) overlay. It's currently required to add this overlay in order to install `gotop`:
+
+```shell
+sudo layman -a guru
+sudo emerge gotop
+```
+
### OSX
gotop can be installed with [Homebrew](https://brew.sh/); you'll need to tap the recipe. If you'd previously tapped cjbassi's recipe, you'll want to untap that first. The old version of gotop is also included in Homebrew's core library, and that will always be chosen before any taps, so you have to specify the tap specifically.
@@ -48,7 +54,7 @@ gotop can be installed with [Homebrew](https://brew.sh/); you'll need to tap the
brew uninstall gotop # If previously installed
brew untap cjbassi/gotop # If previously tapped
brew tap xxxserxxx/gotop
-brew install xxxserxxx/gotop
+brew install xxxserxxx/gotop/gotop
```
### Prebuilt binaries
@@ -146,10 +152,7 @@ and these are separated by spaces.
3. Spaces are compressed (so you can do limited visual formatting)
4. Legal widget names are: cpu, disk, mem, temp, batt, net, procs
5. Widget names are not case sensitive
-4. The simplest row is a single widget, by name, e.g.
- ```
- cpu
- ```
+4. The simplest row is a single widget, by name, e.g. `cpu`
5. **Weights**
1. Widgets with no weights have a weight of 1.
2. If multiple widgets are put on a row with no weights, they will all have
@@ -157,29 +160,35 @@ and these are separated by spaces.
3. Weights are integers
4. A widget will have a width proportional to its weight divided by the
total weight count of the row. E.g.,
+
```
cpu net
disk/2 mem/4
```
+
The first row will have two widgets: the CPU and network widgets; each
will be 50% of the total width wide. The second row will have two
widgets: disk and memory; the first will be 2/6 ~= 33% wide, and the
second will be 5/7 ~= 67% wide (or, memory will be twice as wide as disk).
-9. If prefixed by a number and colon, the widget will span that number of
- rows downward. E.g.
- ```
- mem 2:cpu
- net
- ```
- Here, memory and network will be in the same row as CPU, one over the other,
- and each half as high as CPU; it'll look like this:
- ```
- +------+------+
- | Mem | |
- +------+ CPU |
- | Net | |
- +------+------+
- ```
+9. If prefixed by a number and colon, the widget will span that number of
+ rows downward. E.g.
+
+ ```
+ mem 2:cpu
+ net
+ ```
+
+ Here, memory and network will be in the same row as CPU, one over the other,
+ and each half as high as CPU; it'll look like this:
+
+ ```
+ +------+------+
+ | Mem | |
+ +------+ CPU |
+ | Net | |
+ +------+------+
+ ```
+
10. Negative, 0, or non-integer weights will be recorded as "1". Same for row
spans.
11. Unrecognized widget names will cause the application to abort.
@@ -234,6 +243,10 @@ Interfaces can also be ignored using `!`
- [goreleaser/nfpm](https://github.com/goreleaser/nfpm)
- [distatus/battery](https://github.com/distatus/battery)
+## History
+
+The original author of gotop started a new tool in Rust, called [ytop](https://github.com/cjbassi/ytop). This repository is a fork of original gotop project with a new maintainer.
+
## Stargazers over time
[![Stargazers over time](https://starcharts.herokuapp.com/xxxserxxx/gotop.svg)](https://starcharts.herokuapp.com/xxxserxxx/gotop)
diff --git a/cmd/gotop/main.go b/cmd/gotop/main.go
index 90f6726..9971b23 100644
--- a/cmd/gotop/main.go
+++ b/cmd/gotop/main.go
@@ -8,7 +8,6 @@ import (
"os"
"os/signal"
"path/filepath"
- "plugin"
"strconv"
"strings"
"syscall"
@@ -17,12 +16,12 @@ import (
docopt "github.com/docopt/docopt.go"
ui "github.com/gizak/termui/v3"
"github.com/prometheus/client_golang/prometheus/promhttp"
+ "github.com/shibukawa/configdir"
"github.com/xxxserxxx/gotop/v3"
"github.com/xxxserxxx/gotop/v3/colorschemes"
"github.com/xxxserxxx/gotop/v3/layout"
"github.com/xxxserxxx/gotop/v3/logging"
- "github.com/xxxserxxx/gotop/v3/utils"
w "github.com/xxxserxxx/gotop/v3/widgets"
)
@@ -39,7 +38,7 @@ const (
var (
// TODO: Set this at compile time; having to check this in sucks.
- Version = "3.5.1"
+ Version = "3.6.0"
conf gotop.Config
help *w.HelpMenu
bar *w.StatusBar
@@ -53,7 +52,12 @@ var (
// TODO: Virtual devices from Prometeus metrics @feature
// TODO: Abstract out the UI toolkit. mum4k/termdash, VladimirMarkelov/clui, gcla/gowid, rivo/tview, marcusolsson/tui-go might work better for some OS/Archs. Performance/memory use comparison would be interesting.
func parseArgs(conf *gotop.Config) error {
- usage := `
+ cds := conf.ConfigDir.QueryFolders(configdir.All)
+ cpaths := make([]string, len(cds))
+ for i, p := range cds {
+ cpaths[i] = p.Path
+ }
+ usage := fmt.Sprintf(`
Usage: gotop [options]
Options:
@@ -73,7 +77,8 @@ Options:
-x, --export=PORT Enable metrics for export on the specified port.
-X, --extensions=NAMES Enables the listed extensions. This is a comma-separated list without the .so suffix. The current and config directories will be searched.
--test Runs tests and exits with success/failure code
-
+ --print-paths List out the paths that gotop will look for gotop.conf, layouts, color schemes, and extensions
+ --print-keys Show the keyboard bindings
Built-in layouts:
default
@@ -89,7 +94,14 @@ Colorschemes:
solarized16-light
monokai
vice
-`
+
+Colorschemes and layouts that are not built-in are searched for (in order) in:
+%s
+The first path in this list is always the cwd.
+
+Log files are stored in %s
+
+`, strings.Join(cpaths, ", "), filepath.Join(conf.ConfigDir.QueryCacheFolder().Path, logging.LOGFILE))
var err error
conf.Colorscheme, err = colorschemes.FromName(conf.ConfigDir, "default")
@@ -158,6 +170,46 @@ Colorschemes:
if val, _ := args["--test"]; val != nil {
conf.Test = val.(bool)
}
+ if args["--print-paths"].(bool) {
+ paths := make([]string, 0)
+ for _, d := range conf.ConfigDir.QueryFolders(configdir.All) {
+ paths = append(paths, d.Path)
+ }
+ fmt.Println(strings.Join(paths, "\n"))
+ os.Exit(0)
+ }
+ if args["--print-keys"].(bool) {
+ fmt.Println(`
+Quit: q or <C-c>
+Process navigation:
+ k and <Up>: up
+ j and <Down>: down
+ <C-u>: half page up
+ <C-d>: half page down
+ <C-b>: full page up
+ <C-f>: full page down
+ gg and <Home>: jump to top
+ G and <End>: jump to bottom
+Process actions:
+ <Tab>: toggle process grouping
+ dd: kill selected process or group of processes with SIGTERM
+ d3: kill selected process or group of processes with SIGQUIT
+ d9: kill selected process or group of processes with SIGKILL
+Process sorting
+ c: CPU
+ m: Mem
+ p: PID
+Process filtering:
+ /: start editing filter
+ (while editing):
+ <Enter> accept filter
+ <C-c> and <Escape>: clear filter
+CPU and Mem graph scaling:
+ h: scale in
+ l: scale out
+?: toggles keybind help menu`)
+ os.Exit(0)
+ }
return nil
}
@@ -347,12 +399,10 @@ func eventLoop(c gotop.Config, grid *layout.MyGrid) {
}
func makeConfig() gotop.Config {
- ld := utils.GetLogDir(appName)
- cd := utils.GetConfigDir(appName)
+ cd := configdir.New("", appName)
+ cd.LocalPath, _ = filepath.Abs(".")
conf = gotop.Config{
ConfigDir: cd,
- LogDir: ld,
- LogFile: "errors.log",
GraphHorizontalScale: 7,
HelpVisible: false,
UpdateInterval: time.Second,
@@ -369,39 +419,56 @@ func makeConfig() gotop.Config {
// TODO: mpd visualizer widget
func main() {
+ // This is just to make sure gotop returns a useful exit code, but also
+ // executes all defer statements and so cleans up before exit. Sort of
+ // annoying work-around for a lack of a clean way to exit Go programs
+ // with exit codes.
+ ec := run()
+ if ec > 0 {
+ if ec < 2 {
+ fmt.Printf("errors encountered; check the log file %s\n", filepath.Join(conf.ConfigDir.QueryCacheFolder().Path, logging.LOGFILE))
+ }
+ }
+ os.Exit(ec)
+}
+
+func run() int {
// Set up default config
conf := makeConfig()
- // Parse the config file
- cfn := filepath.Join(conf.ConfigDir, "gotop.conf")
- if cf, err := os.Open(cfn); err == nil {
- err := gotop.Parse(cf, &conf)
- if err != nil {
- stderrLogger.Fatalf("error parsing config file %v", err)
- }
+ // Find the config file; look in (1) local, (2) user, (3) global
+ err := conf.Load()
+ if err != nil {
+ fmt.Printf("failed to parse config file: %s\n", err)
+ return 2
}
// Override with command line arguments
- err := parseArgs(&conf)
+ err = parseArgs(&conf)
if err != nil {
- stderrLogger.Fatalf("failed to parse cli args: %v", err)
+ fmt.Printf("parsing CLI args: %s\n", err)
+ return 2
}
logfile, err := logging.New(conf)
if err != nil {
- stderrLogger.Fatalf("failed to setup log file: %v", err)
+ fmt.Printf("failed to setup log file: %v\n", err)
+ return 2
}
defer logfile.Close()
- lstream := getLayout(conf)
+ lstream, err := getLayout(conf)
+ if err != nil {
+ stderrLogger.Print(err)
+ return 1
+ }
ly := layout.ParseLayout(lstream)
- loadExtensions(conf)
-
if conf.Test {
- os.Exit(runTests(conf))
+ return runTests(conf)
}
if err := ui.Init(); err != nil {
- stderrLogger.Fatalf("failed to initialize termui: %v", err)
+ stderrLogger.Print(err)
+ return 1
}
defer ui.Close()
@@ -413,7 +480,8 @@ func main() {
grid, err := layout.Layout(ly, conf)
if err != nil {
- stderrLogger.Fatalf("failed to initialize termui: %v", err)
+ stderrLogger.Print(err)
+ return 1
}
termWidth, termHeight := ui.TerminalDimensions()
@@ -437,76 +505,37 @@ func main() {
}()
}
eventLoop(conf, grid)
+ return 0
}
-func getLayout(conf gotop.Config) io.Reader {
+func getLayout(conf gotop.Config) (io.Reader, error) {
switch conf.Layout {
case "-":
- return os.Stdin
+ return os.Stdin, nil
case "default":
- return strings.NewReader(defaultUI)
+ return strings.NewReader(defaultUI), nil
case "minimal":
- return strings.NewReader(minimalUI)
+ return strings.NewReader(minimalUI), nil
case "battery":
- return strings.NewReader(batteryUI)
+ return strings.NewReader(batteryUI), nil
case "procs":
- return strings.NewReader(procsUI)
+ return strings.NewReader(procsUI), nil
case "kitchensink":
- return strings.NewReader(kitchensink)
+ return strings.NewReader(kitchensink), nil
default:
- fp := filepath.Join(conf.ConfigDir, conf.Layout)
- fin, err := os.Open(fp)
- if err != nil {
- fin, err = os.Open(conf.Layout)
- if err != nil {
- log.Fatalf("Unable to open layout file %s or ./%s", fp, conf.Layout)
+ folder := conf.ConfigDir.QueryFolderContainsFile(conf.Layout)
+ if folder == nil {
+ paths := make([]string, 0)
+ for _, d := range conf.ConfigDir.QueryFolders(configdir.Existing) {
+ paths = append(paths, d.Path)
}
+ return nil, fmt.Errorf("unable find layout file %s in %s", conf.Layout, strings.Join(paths, ", "))
}
- return fin
- }
-}
-
-func loadExtensions(conf gotop.Config) {
- var hasError bool
- for _, ex := range conf.Extensions {
- exf := ex + ".so"
- fn := exf
- _, err := os.Stat(fn)
- if err != nil && os.IsNotExist(err) {
- log.Printf("no plugin %s found in current directory", fn)
- fn = filepath.Join(conf.ConfigDir, exf)
- _, err = os.Stat(fn)
- if err != nil || os.IsNotExist(err) {
- hasError = true
- log.Printf("no plugin %s found in config directory", fn)
- continue
- }
- }
- p, err := plugin.Open(fn)
- if err != nil {
- hasError = true
- log.Printf(err.Error())
- continue
- }
- init, err := p.Lookup("Init")
+ lo, err := folder.ReadFile(conf.Layout)
if err != nil {
- hasError = true
- log.Printf(err.Error())
- continue
+ return nil, err
}
-
- initFunc, ok := init.(func())
- if !ok {
- hasError = true
- log.Printf(err.Error())
- continue
- }
- initFunc()
- }
- if hasError {
- ui.Close()
- fmt.Printf("Error initializing requested plugins; check the log file %s\n", filepath.Join(conf.ConfigDir, conf.LogFile))
- os.Exit(1)
+ return strings.NewReader(string(lo)), nil
}
}
diff --git a/colorschemes/registry.go b/colorschemes/registry.go
index d79271d..b6263c9 100644
--- a/colorschemes/registry.go
+++ b/colorschemes/registry.go
@@ -3,8 +3,10 @@ package colorschemes
import (
"encoding/json"
"fmt"
- "io/ioutil"
"path/filepath"
+ "strings"
+
+ "github.com/shibukawa/configdir"
)
var registry map[string]Colorscheme
@@ -15,15 +17,12 @@ func init() {
}
}
-func FromName(confDir string, c string) (Colorscheme, error) {
- cs, ok := registry[c]
- if !ok {
- cs, err := getCustomColorscheme(confDir, c)
- if err != nil {
- return cs, err
- }
+func FromName(confDir configdir.ConfigDir, c string) (Colorscheme, error) {
+ if cs, ok := registry[c]; ok {
+ return cs, nil
}
- return cs, nil
+ cs, err := getCustomColorscheme(confDir, c)
+ return cs, err
}
func register(name string, c Colorscheme) {
@@ -34,12 +33,20 @@ func register(name string, c Colorscheme) {
}
// getCustomColorscheme tries to read a custom json colorscheme from <configDir>/<name>.json
-func getCustomColorscheme(confDir string, name string) (Colorscheme, error) {
+func getCustomColorscheme(confDir configdir.ConfigDir, name string) (Colorscheme, error) {
var cs Colorscheme
- filePath := filepath.Join(confDir, name+".json")
- dat, err := ioutil.ReadFile(filePath)
+ fn := name + ".json"
+ folder := confDir.QueryFolderContainsFile(fn)
+ if folder == nil {
+ paths := make([]string, 0)
+ for _, d := range confDir.QueryFolders(configdir.Existing) {
+ paths = append(paths, d.Path)
+ }
+ return cs, fmt.Errorf("failed to find colorscheme file %s in %s", fn, strings.Join(paths, ", "))
+ }
+ dat, err := folder.ReadFile(fn)
if err != nil {
- return cs, fmt.Errorf("failed to read colorscheme file: %v", err)
+ return cs, fmt.Errorf("failed to read colorscheme file %s: %v", filepath.Join(folder.Path, fn), err)
}
err = json.Unmarshal(dat, &cs)
if err != nil {
diff --git a/config.go b/config.go
index d072dee..41b5278 100644
--- a/config.go
+++ b/config.go
@@ -4,19 +4,20 @@ import (
"bufio"
"fmt"
"io"
+ "log"
+ "os"
"strconv"
"strings"
"time"
+ "github.com/shibukawa/configdir"
"github.com/xxxserxxx/gotop/v3/colorschemes"
"github.com/xxxserxxx/gotop/v3/widgets"
)
// TODO: test, build, release [#119] [#120] [#121]
type Config struct {
- ConfigDir string
- LogDir string
- LogFile string
+ ConfigDir configdir.ConfigDir
GraphHorizontalScale int
HelpVisible bool
@@ -36,7 +37,20 @@ type Config struct {
Test bool
}
-func Parse(in io.Reader, conf *Config) error {
+func (conf *Config) Load() error {
+ var in io.Reader
+ cfn := "gotop.conf"
+ folder := conf.ConfigDir.QueryFolderContainsFile(cfn)
+ if folder != nil {
+ // FIXME: Shouldn't this be looking in folder??
+ if cf, err := os.Open(cfn); err == nil {
+ defer cf.Close()
+ } else {
+ return err
+ }
+ } else {
+ return nil
+ }
r := bufio.NewScanner(in)
var lineNo int
for r.Scan() {
@@ -50,11 +64,11 @@ func Parse(in io.Reader, conf *Config) error {
default:
return fmt.Errorf("invalid config option %s", key)
case "configdir":
- conf.ConfigDir = kv[1]
+ log.Printf("configdir is deprecated. Ignored configdir=%s", kv[1])
case "logdir":
- conf.LogDir = kv[1]
+ log.Printf("logdir is deprecated. Ignored logdir=%s", kv[1])
case "logfile":
- conf.LogFile = kv[1]
+ log.Printf("logfile is deprecated. Ignored logfile=%s", kv[1])
case "graphhorizontalscale":
iv, err := strconv.Atoi(kv[1])
if err != nil {
diff --git a/docs/releasing.md b/docs/releasing.md
index d77b6dd..e87e4de 100644
--- a/docs/releasing.md
+++ b/docs/releasing.md
@@ -6,8 +6,10 @@ Current steps for a release:
3. Tag
4. Push everything
5. When the github workflows complete, finish the draft release and publish.
-6. After the [Homebrew](https://github.com/xxxserxxx/homebrew-gotop) and [AUR](https://github.com/xxxserxxx/gotop-linux] projects are done, check out gotop-linux and run `aurpublish aur` and `aurpublish aur-bin`
-
+6. Wait for the [Homebrew](https://github.com/xxxserxxx/homebrew-gotop) and [AUR](https://github.com/xxxserxxx/gotop-linux] projects to finish building.
+ 1. check out gotop-linux and run `aurpublish aur` and `aurpublish aur-bin`
+ 2. update the hashes in the Nix package (see below), test build, push a pull request
+ 3. notify Homebrew
Homebrew is automatically updated. The AUR project still needs secret
credentials to aurpublish to the AUR repository, so the final publish step is
@@ -18,14 +20,14 @@ Oh, what a tangled web.
Nix adds new and interesting complexities to the release.
+0. Download the gotop src package; run sha256 on it to get the hash
1. cd to the nixpkgs directory
-2. docker run -it --rm --mount type=bind,source="\$(pwd)",target=/mnt nixos/nix sh
-3. cd /mnt
-4. nix-prefetch-url --unpack https://github.com/xxxserxxx/gotop/archive/v3.3.2.tar.gz
-5. Copy the sha256
-6. Update the version and hash in nixpkgs/pkgs/tools/system/gotop/default.nix
-8. In docker, install & run vgo2nix to update deps.nix
-7. nix-build -A gotop
+2. Update the sha256 hash in `pkgs/tools/system/gotop/default.nix`
+2. `docker run -it --rm --mount type=bind,source="\$(pwd)",target=/mnt nixos/nix sh`
+3. `cd /mnt`
+8. install & run vgo2nix to update deps.nix
+7. `nix-build -A gotop`
+8. When it fails, copy the hash and update the
For plugin development:
diff --git a/go.mod b/go.mod
index 38e1380..2b53f3a 100644
--- a/go.mod
+++ b/go.mod
@@ -9,6 +9,7 @@ require (
github.com/mattn/go-runewidth v0.0.4
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/prometheus/client_golang v1.4.1
+ github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0
github.com/shirou/gopsutil v2.18.11+incompatible
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/stretchr/testify v1.4.0
diff --git a/go.sum b/go.sum
index 3cf7498..0a20cb4 100644
--- a/go.sum
+++ b/go.sum
@@ -83,6 +83,8 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
+github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0 h1:Xuk8ma/ibJ1fOy4Ee11vHhUFHQNpHhrBneOCNHVXS5w=
+github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0/go.mod h1:7AwjWCpdPhkSmNAgUv5C7EJ4AbmjEB3r047r3DXWu3Y=
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/logging/logging.go b/logging/logging.go
index 6b023d7..c79b5c8 100644
--- a/logging/logging.go
+++ b/logging/logging.go
@@ -11,16 +11,22 @@ import (
"github.com/xxxserxxx/gotop/v3"
)
+const (
+ LOGFILE = "errors.log"
+)
+
func New(c gotop.Config) (io.WriteCloser, error) {
// create the log directory
- if err := os.MkdirAll(c.LogDir, 0755); err != nil {
- return nil, fmt.Errorf("failed to make the log directory: %v", err)
+ cache := c.ConfigDir.QueryCacheFolder()
+ err := cache.MkdirAll()
+ if err != nil && !os.IsExist(err) {
+ return nil, err
}
w := &RotateWriter{
- filename: filepath.Join(c.LogDir, c.LogFile),
+ filename: filepath.Join(cache.Path, LOGFILE),
maxLogSize: c.MaxLogSize,
}
- err := w.rotate()
+ err = w.rotate()
if err != nil {
return nil, err
}
diff --git a/widgets/batterygauge.go b/widgets/batterygauge.go
index 534c1cf..d447713 100644
--- a/widgets/batterygauge.go
+++ b/widgets/batterygauge.go
@@ -12,6 +12,7 @@ import (
. "github.com/xxxserxxx/gotop/v3/termui"
)
+// FIXME 3.5.1 is 0% always
type BatteryGauge struct {
*Gauge
metric prometheus.Gauge