summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-02-20 19:26:34 -0600
committerSean E. Russell <ser@ser1.net>2020-02-20 19:26:34 -0600
commitaf40172604692131386a04d7d9f59435e6974983 (patch)
treeb52a89f8343c866f193c380a5aa428aa9f5deb67
parent7b09a00230e059129e010039a159ef9ce7aecc11 (diff)
parentcbad9c124ed077c9d9c0fe1abb258edaddb7df0b (diff)
Merge branch 'master' into v3.4.x
-rw-r--r--CHANGELOG.md23
-rw-r--r--README.md17
-rw-r--r--build/nfpm.yml2
-rwxr-xr-xbuild/osx.sh3
-rw-r--r--build/snapcraft.yaml (renamed from snap/snapcraft.yaml)0
-rwxr-xr-xci/script.sh36
-rw-r--r--cmd/gotop/main.go5
-rw-r--r--colorschemes/default_dark.go2
-rw-r--r--colorschemes/registry_test.go20
-rw-r--r--colorschemes/solarized16_dark.go (renamed from colorschemes/solarized16-dark.go)2
-rw-r--r--colorschemes/solarized16_light.go (renamed from colorschemes/solarized16-light.go)2
-rw-r--r--config.go10
-rw-r--r--go.mod2
-rw-r--r--logging/logging_other.go2
-rwxr-xr-xmake.sh151
-rw-r--r--widgets/battery.go21
-rw-r--r--widgets/net.go1
-rw-r--r--widgets/temp.go2
18 files changed, 191 insertions, 110 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9b15345..f4468be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,7 +13,7 @@ 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.4.x] -
+## [3.4.x] - ??
- Added: metrics. If run with the `--export :2112` flag (`:2112` is a port),
metrics are exposed as Prometheus metrics on that port and can be HTTP
@@ -21,6 +21,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added: a battery gauge as a `power` widget; battery as a bar rather than
a histogram.
+## [3.3.2] - ??
+
+- Fixes #15, crash caused by battery widget when some accessories have batteries
+- Fixes #57, colors with dashes in the name not found.
+- Also, cjbassi/gotop#127 and cjbassi/gotop#130 were released back in v3.1.0.
+
## [3.3.1] - 2020-02-18
- Fixed: Fixes a layout bug where, if columns filled up early, widgets would be
@@ -65,21 +71,6 @@ unmaintained by cjbassi.
- Added: Adds the ability to lay out the UI using a text file
- Changed: the project filesystem layout to be more idiomatic
-## [Unreleased]
-
-### Added
-
-- Add snap package [#119] [#120] [#121]
-- Process list scroll indicator [#127] [#130]
-- Preliminary OpenBSD support [#112] [#117] [#118]
-
-### Fixed
-
-- Fix process localization issues on macOS [#124]
-- Fix miscellaneous issues on FreeBSD [#134] [#145]
-- Fix spelling of "Tx" to "TX" [#129]
-- Rerender statusbar on every tick [#128]
-
## [3.0.0] - 2019-02-22
### Added
diff --git a/README.md b/README.md
index 547c26d..0a47092 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,23 @@ Visit [here](https://github.com/xxxserxxx/gotop/releases) with your web browser
Unzip it and then move `gotop` into your `$PATH` somewhere. If you're on a Debian or Redhat derivative, you can download an `.rpm` or `.deb` to install.
+### Building
+
+The easiest way is to
+```
+go get github.com/xxxserxxx/gotop/cmd/gotop
+```
+
+To create the cross-compile builds, there's a `make.sh` script; it has a lot of dependencies and has only been tested on my computer. When it works, it creates archives for numerous OSes & architectures. There's no testing for whether dependencies are available; it assumes they are and will fail in strange ways when they aren't.
+
+- bash
+- Go
+- zip
+- nfpm (for deb & rpm)
+- docker (for darwin)
+
+It is *just* smart enough to not rebuild things when it doesn't have to, and it tries to keep the darwin docker container around so it's not building from scratch every time. There are no guarantees.
+
## Usage
### Keybinds
diff --git a/build/nfpm.yml b/build/nfpm.yml
index 67b575b..69852e0 100644
--- a/build/nfpm.yml
+++ b/build/nfpm.yml
@@ -12,4 +12,4 @@ homepage: "https://github.com/xxxserxxx/gotop"
license: "GNU Affero General Public License v3.0"
bindir: "/usr/local/bin"
files:
- dist/gotop: "/usr/local/bin/gotop"
+ build/gotop: "/usr/local/bin/gotop"
diff --git a/build/osx.sh b/build/osx.sh
new file mode 100755
index 0000000..9d76d59
--- /dev/null
+++ b/build/osx.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+cd /mnt
+./make.sh darwin
diff --git a/snap/snapcraft.yaml b/build/snapcraft.yaml
index de17ee7..de17ee7 100644
--- a/snap/snapcraft.yaml
+++ b/build/snapcraft.yaml
diff --git a/ci/script.sh b/ci/script.sh
deleted file mode 100755
index 27e6cdf..0000000
--- a/ci/script.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env bash
-
-function main {
- # Check if any command failed
- ERROR=false
-
- GOARCH=${_GOARCH}
- GOOS=${_GOOS}
-
- if [[ ! ${GOARCH} ]]; then
- exit
- fi
-
- env GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -o ${NAME} || ERROR=true
-
- mkdir -p dist
-
- if [[ ${GOARCH} == "arm64" ]]; then
- FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_arm8
- else
- FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_${GOARCH}${GOARM}
- fi
-
- tar -czf dist/${FILE}.tgz ${NAME} || ERROR=true
-
- if [[ ${GOOS} == "linux" && ${GOARCH} == "amd64" ]]; then
- make all || ERROR=true
- rm dist/gotop
- fi
-
- if [ ${ERROR} == "true" ]; then
- exit 1
- fi
-}
-
-main
diff --git a/cmd/gotop/main.go b/cmd/gotop/main.go
index 9d1f0a5..c708b39 100644
--- a/cmd/gotop/main.go
+++ b/cmd/gotop/main.go
@@ -44,6 +44,11 @@ var (
)
// TODO: Add tab completion for Linux https://gist.github.com/icholy/5314423
+// TODO: state:merge #135 linux console font (cmatsuoka/console-font)
+// TODO: state:deferred 157 FreeBSD fixes & Nvidia GPU support (kraust/master). Significant CPU use impact for NVidia changes.
+// TODO: Virtual devices from Prometeus metrics @feature
+// TODO: Export Prometheus metrics @feature
+// TODO: state:merge #167 configuration file (jrswab/configFile111)
func parseArgs(conf *gotop.Config) error {
usage := `
Usage: gotop [options]
diff --git a/colorschemes/default_dark.go b/colorschemes/default_dark.go
index 7ddb5f7..849f85b 100644
--- a/colorschemes/default_dark.go
+++ b/colorschemes/default_dark.go
@@ -1,7 +1,7 @@
package colorschemes
func init() {
- register("defaultdark", Colorscheme{
+ register("default-dark", Colorscheme{
Fg: 235,
Bg: -1,
diff --git a/colorschemes/registry_test.go b/colorschemes/registry_test.go
new file mode 100644
index 0000000..e4216ab
--- /dev/null
+++ b/colorschemes/registry_test.go
@@ -0,0 +1,20 @@
+package colorschemes
+
+import (
+ "reflect"
+ "testing"
+)
+
+func TestColorRegistry(t *testing.T) {
+ colors := []string{"default", "default-dark", "solarized", "solarized16-dark", "solarized16-light", "monokai", "vice"}
+ zeroCS := Colorscheme{}
+ for _, cn := range colors {
+ c, e := FromName("", cn)
+ if e != nil {
+ t.Errorf("unexpected error fetching built-in color %s: %s", cn, e)
+ }
+ if reflect.DeepEqual(c, zeroCS) {
+ t.Error("expected a colorscheme, but got back a zero value.")
+ }
+ }
+}
diff --git a/colorschemes/solarized16-dark.go b/colorschemes/solarized16_dark.go
index 202dbab..354991b 100644
--- a/colorschemes/solarized16-dark.go
+++ b/colorschemes/solarized16_dark.go
@@ -3,7 +3,7 @@ package colorschemes
// This scheme assumes the terminal already uses Solarized. Only DiskBar is
// different between dark/light.
func init() {
- register("solarized16dark", Colorscheme{
+ register("solarized16-dark", Colorscheme{
Fg: -1,
Bg: -1,
diff --git a/colorschemes/solarized16-light.go b/colorschemes/solarized16_light.go
index 351fe4e..0fae397 100644
--- a/colorschemes/solarized16-light.go
+++ b/colorschemes/solarized16_light.go
@@ -3,7 +3,7 @@ package colorschemes
// This scheme assumes the terminal already uses Solarized. Only DiskBar is
// different between dark/light.
func init() {
- register("solarized16light", Colorscheme{
+ register("solarized16-light", Colorscheme{
Fg: -1,
Bg: -1,
diff --git a/config.go b/config.go
index 946ebdb..fc6e521 100644
--- a/config.go
+++ b/config.go
@@ -12,15 +12,7 @@ import (
"github.com/xxxserxxx/gotop/widgets"
)
-// TODO: Cross-compiling for darwin, openbsd requiring native procs & temps
-// TODO: Merge #184 or #177 degree symbol (BartWillems:master, fleaz:master)
-// TODO: Merge #169 % option for network use (jrswab:networkPercentage)
-// TODO: Merge #167 configuration file (jrswab:configFile111)
-// TODO: Merge #157 FreeBSD fixes & Nvidia GPU support (kraust:master)
-// TODO: Merge #156 Added temperatures for NVidia GPUs (azak-azkaran:master)
-// TODO: Merge #135 linux console font (cmatsuoka:console-font)
-// TODO: Export Prometheus metrics @feature
-// TODO: Virtual devices from Prometeus metrics @feature
+// TODO: test, build, release [#119] [#120] [#121]
type Config struct {
ConfigDir string
LogDir string
diff --git a/go.mod b/go.mod
index 6058002..639a0d1 100644
--- a/go.mod
+++ b/go.mod
@@ -15,4 +15,4 @@ require (
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
)
-go 1.13
+go 1.12
diff --git a/logging/logging_other.go b/logging/logging_other.go
index f5705d6..fd88b83 100644
--- a/logging/logging_other.go
+++ b/logging/logging_other.go
@@ -1,4 +1,4 @@
-// +build linux openbsd freebsd
+// +build linux openbsd freebsd darwin
// +build !arm64
package logging
diff --git a/make.sh b/make.sh
index 132657a..961e282 100755
--- a/make.sh
+++ b/make.sh
@@ -4,7 +4,8 @@ export VERSION=$(go run ./cmd/gotop -V)
rm -f build.log
-function candz() {
+# Set up some common environment variables
+function out() {
export GOOS=$1
export GOARCH=$2
OUT=build/gotop_${VERSION}_${GOOS}_${GOARCH}
@@ -12,64 +13,132 @@ function candz() {
export GOARM=$3
OUT=${OUT}_v${GOARM}
fi
- OUT=${OUT}.zip
- if [[ -e $OUT ]]; then
- echo SKIP $OUT
- return
- fi
D=build/gotop
if [[ $GOOS == "windows" ]]; then
D=${D}.exe
+ AR=${OUT}.zip
+ else
+ AR=${OUT}.tgz
fi
+}
+# Clean up environment variables
+function uset() {
+ unset GOOS GOARCH GOARM CGO_ENABLED OUT D AR
+}
+# Compile something that can be cross-compiled without docker
+function c() {
+ out $1 $2 $3
go build -o $D ./cmd/gotop >> build.log 2>&1
if [[ $? -ne 0 ]]; then
printenv | grep GO >> build.log
- echo "############### FAILED ###############" >> build.log
- echo >> build.log
- echo >> build.log
- echo FAILED $OUT
+ echo "############### FAILED ###############"
+ echo FAILED COMPILE $OUT
+ fi
+}
+# Zip up something that's been compiled
+function z() {
+ out $1 $2 $3
+ if [[ -e $AR ]]; then
+ echo SKIP $AR
return
fi
- unset GOOS GOARCH GOARM CGO_ENABLED
cd build
- zip $(basename $OUT) $(basename $D) >> ../build.log 2>&1
- cd ..
- rm -f $D
+ if [[ $GOOS == "windows" ]]; then
+ zip -q $(basename $AR) $(basename $D)
+ else
+ tar -czf $(basename $AR) $(basename $D)
+ fi
if [[ $? -ne 0 ]]; then
- echo "############### FAILED ###############" >> build.log
- echo >> build.log
- echo >> build.log
- echo FAILED $OUT
+ echo "############### FAILED ###############"
+ echo FAILED ARCHIVE $AR
+ cd ..
return
fi
- echo BUILT $OUT
+ cd ..
+ echo BUILT $AR
}
-
-candz linux arm64
-for x in 5 6 7; do
- candz linux arm $x
-done
-for x in 386 amd64; do
- candz linux $x
-
- sed -i "s/arch: .*/arch: \"${x}\"/" build/nfpm.yml
+# Do c(), then z(), and then clean up.
+function candz() {
+ unset OUT
+ out $1 $2 $3
+ local AR=${OUT}.zip
+ if [[ -e $AR ]]; then
+ echo SKIP $AR
+ return
+ fi
+ c $1 $2 $3
+ z $1 $2 $3
+ rm -f $D
+ uset
+}
+# Build the deb and rpm archives
+function nfpmAR() {
+ out $1 $2 $3
+ sed -i "s/arch: .*/arch: \"${GOARCH}\"/" build/nfpm.yml
for y in rpm deb; do
- OUT=build/gotop_${VERSION}_linux_${x}.${y}
- if [[ -e $OUT ]]; then
- echo SKIP $OUT
+ local AR=build/gotop_${VERSION}_linux_${GOARCH}.${y}
+ if [[ -e $AR ]]; then
+ echo SKIP $AR
else
- echo Building $OUT
- nfpm pkg -t ${OUT} -f build/nfpm.yml
+ echo Building $AR
+ nfpm pkg -t ${AR} -f build/nfpm.yml
fi
done
+}
+# Cross-compile the darwin executable. This requires docker.
+function cdarwinz() {
+ if [[ ! -d darwin ]]; then
+ git clone . darwin
+ cd darwin
+ else
+ cd darwin
+ git pull
+ fi
+ export CGO_ENABLED=1
+ if [[ `docker images -q gotopdarwin` == "" ]]; then
+ docker run -it --name osxcross --mount type=bind,source="$(pwd)",target=/mnt dockercore/golang-cross /bin/bash /mnt/build/osx.sh
+ local ID=`docker commit osxcross dockercore/golang-cross | cut -d : -f 2`
+ docker tag $ID gotopdarwin
+ else
+ docker run -it --name osxcross --mount type=bind,source="$(pwd)",target=/mnt gotopdarwin /bin/bash /mnt/build/osx.sh
+ fi
+ cd ..
+ mv darwin/build/gotop*darwin*.tgz build/
+ docker rm osxcross
+ uset
+}
- candz windows $x
- candz freebsd $x
+##########################################################
+# Iterate through the OS/ARCH permutations and build an
+# archive for each, using the previously defined functions.
+if [[ $1 == "darwin" ]]; then
+ export MACOSX_DEPLOYMENT_TARGET=10.10.0
+ export CC=o64-clang
+ export CXX=o64-clang++
+ export CGO_ENABLED=1
+ c darwin 386
+ z darwin 386
+ c darwin amd64
+ z darwin amd64
+else
+ candz linux arm64
- export CGO_ENABLED=1
- candz darwin $x
- candz openbsd $x
- unset CGO_ENABLED
-done
+ for x in 5 6 7; do
+ candz linux arm $x
+ done
-rm -f build/gotop
+ for x in 386 amd64; do
+ c linux $x
+ z linux $x
+ nfpmAR linux $x
+ rm -f $D
+ uset
+
+ candz windows $x
+ candz freebsd $x
+
+ # TODO Preliminary OpenBSD support [#112] [#117] [#118]
+ # candz openbsd $x
+ done
+ cdarwinz
+fi
diff --git a/widgets/battery.go b/widgets/battery.go
index fb28971..b47cac4 100644
--- a/widgets/battery.go
+++ b/widgets/battery.go
@@ -73,8 +73,25 @@ func (b *BatteryWidget) Scale(i int) {
func (self *BatteryWidget) update() {
batteries, err := battery.GetAll()
if err != nil {
- log.Printf("failed to get battery info: %v", err)
- return
+ switch errt := err.(type) {
+ case battery.ErrFatal:
+ log.Printf("fatal error fetching battery info: %v", err)
+ return
+ case battery.Errors:
+ batts := make([]*battery.Battery, 0)
+ for i, e := range errt {
+ if e == nil {
+ batts = append(batts, batteries[i])
+ } else {
+ log.Printf("recoverable error fetching battery info; skipping battery: %v", e)
+ }
+ }
+ if len(batts) < 1 {
+ log.Print("no usable batteries found")
+ return
+ }
+ batteries = batts
+ }
}
for i, battery := range batteries {
id := makeId(i)
diff --git a/widgets/net.go b/widgets/net.go
index daacbc7..1326fdc 100644
--- a/widgets/net.go
+++ b/widgets/net.go
@@ -30,6 +30,7 @@ type NetWidget struct {
recvMetric prometheus.Counter
}
+// TODO: state:merge #169 % option for network use (jrswab/networkPercentage)
func NewNetWidget(netInterface string) *NetWidget {
recvSparkline := ui.NewSparkline()
recvSparkline.Data = []int{}
diff --git a/widgets/temp.go b/widgets/temp.go
index 7ae3ef1..f9fec84 100644
--- a/widgets/temp.go
+++ b/widgets/temp.go
@@ -31,6 +31,7 @@ type TempWidget struct {
tempsMetric map[string]prometheus.Gauge
}
+// TODO: state:deferred 156 Added temperatures for NVidia GPUs (azak-azkaran/master). Crashes on non-nvidia machines.
func NewTempWidget(tempScale TempScale) *TempWidget {
self := &TempWidget{
Block: ui.NewBlock(),
@@ -100,6 +101,7 @@ func (self *TempWidget) Draw(buf *ui.Buffer) {
image.Pt(self.Inner.Min.X, self.Inner.Min.Y+y),
)
+ // TODO: state:merge #184 or #177 degree symbol (BartWillems/master, fleaz/master)
switch self.TempScale {
case Fahrenheit:
buf.SetString(