Fixes the directory structure.

This commit is contained in:
Sean E. Russell 2020-02-13 10:15:52 -06:00
parent 4bfe0251a8
commit 7e5c0c969c
41 changed files with 42 additions and 41 deletions

View File

@ -1,5 +1,3 @@
### **NO LONGER MAINTAINED.** Future development has moved to [ytop](https://github.com/cjbassi/ytop), a Rust port of gotop.
<div align="center">
<a href="./assets/logo">
@ -116,6 +114,8 @@ To make a custom colorscheme, check out the [template](./colorschemes/template.g
`-s`, `--statusbar` Show a statusbar with the time.
`-b`, `--battery` Show battery level widget (`minimal` turns off). [preview](./assets/screenshots/battery.png)
`-i`, `--interface=NAME` Select network interface [default: all].
`-l`, `--layout=NAME` Choose a layout from definitions in the \$XDG_CONFIG_HOME/gotop directory
`--layout-file=NAME` Provide a path to a layout file to use (useful for mucking about with layouts)
## Built With

View File

@ -17,12 +17,12 @@ import (
docopt "github.com/docopt/docopt.go"
ui "github.com/gizak/termui/v3"
"github.com/cjbassi/gotop"
"github.com/cjbassi/gotop/colorschemes"
"github.com/cjbassi/gotop/src/config"
"github.com/cjbassi/gotop/src/layout"
"github.com/cjbassi/gotop/src/logging"
"github.com/cjbassi/gotop/src/utils"
w "github.com/cjbassi/gotop/src/widgets"
"github.com/cjbassi/gotop/layout"
"github.com/cjbassi/gotop/logging"
"github.com/cjbassi/gotop/utils"
w "github.com/cjbassi/gotop/widgets"
)
const (
@ -34,14 +34,14 @@ const (
)
var (
conf config.Config
conf gotop.Config
help *w.HelpMenu
bar *w.StatusBar
statusbar bool
stderrLogger = log.New(os.Stderr, "", 0)
)
func parseArgs() (config.Config, error) {
func parseArgs() (gotop.Config, error) {
usage := `
Usage: gotop [options]
@ -70,7 +70,7 @@ Colorschemes:
ld := utils.GetLogDir(appName)
cd := utils.GetConfigDir(appName)
conf = config.Config{
conf = gotop.Config{
ConfigDir: cd,
LogDir: ld,
LogPath: filepath.Join(ld, "errors.log"),
@ -164,7 +164,7 @@ func handleColorscheme(c string) (colorschemes.Colorscheme, error) {
}
// getCustomColorscheme tries to read a custom json colorscheme from <configDir>/<name>.json
func getCustomColorscheme(c config.Config, name string) (colorschemes.Colorscheme, error) {
func getCustomColorscheme(c gotop.Config, name string) (colorschemes.Colorscheme, error) {
var cs colorschemes.Colorscheme
filePath := filepath.Join(c.ConfigDir, name+".json")
dat, err := ioutil.ReadFile(filePath)
@ -178,13 +178,13 @@ func getCustomColorscheme(c config.Config, name string) (colorschemes.Colorschem
return cs, nil
}
func setDefaultTermuiColors(c config.Config) {
func setDefaultTermuiColors(c gotop.Config) {
ui.Theme.Default = ui.NewStyle(ui.Color(c.Colorscheme.Fg), ui.Color(c.Colorscheme.Bg))
ui.Theme.Block.Title = ui.NewStyle(ui.Color(c.Colorscheme.BorderLabel), ui.Color(c.Colorscheme.Bg))
ui.Theme.Block.Border = ui.NewStyle(ui.Color(c.Colorscheme.BorderLine), ui.Color(c.Colorscheme.Bg))
}
func eventLoop(c config.Config, grid *layout.MyGrid) {
func eventLoop(c gotop.Config, grid *layout.MyGrid) {
drawTicker := time.NewTicker(c.UpdateInterval).C
// handles kill signal sent to gotop
@ -341,7 +341,7 @@ func eventLoop(c config.Config, grid *layout.MyGrid) {
}
}
func setupLogfile(c config.Config) (*os.File, error) {
func setupLogfile(c gotop.Config) (*os.File, 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)

View File

@ -1,10 +1,10 @@
package config
package gotop
import (
"time"
"github.com/cjbassi/gotop/colorschemes"
"github.com/cjbassi/gotop/src/widgets"
"github.com/cjbassi/gotop/widgets"
)
type Config struct {

View File

@ -5,8 +5,9 @@ import (
"log"
"sort"
"github.com/cjbassi/gotop/src/config"
"github.com/cjbassi/gotop/src/widgets"
"github.com/cjbassi/gotop"
"github.com/cjbassi/gotop/widgets"
ui "github.com/gizak/termui/v3"
)
@ -28,7 +29,7 @@ type MyGrid struct {
var widgetNames []string = []string{"cpu", "disk", "mem", "temp", "net", "procs", "batt"}
func Layout(wl layout, c config.Config) (*MyGrid, error) {
func Layout(wl layout, c gotop.Config) (*MyGrid, error) {
rowDefs := wl.Rows
uiRows := make([]ui.GridItem, 0)
numRows := countNumRows(wl.Rows)
@ -57,7 +58,7 @@ func Layout(wl layout, c config.Config) (*MyGrid, error) {
// if there's a row span widget in the row; in this case, it'll consume as many
// rows as the largest row span object in the row, and produce an uber-row
// containing all that stuff. It returns a slice without the consumed elements.
func processRow(c config.Config, numRows int, rowDefs [][]widgetRule) (ui.GridItem, [][]widgetRule) {
func processRow(c gotop.Config, numRows int, rowDefs [][]widgetRule) (ui.GridItem, [][]widgetRule) {
// Recursive function #3. See the comment in deepFindProc.
if len(rowDefs) < 1 {
return ui.GridItem{}, [][]widgetRule{}
@ -104,7 +105,7 @@ func processRow(c config.Config, numRows int, rowDefs [][]widgetRule) (ui.GridIt
return ui.NewRow(1.0/float64(numRows), uiColumns...), rowDefs
}
func makeWidget(c config.Config, widRule widgetRule) interface{} {
func makeWidget(c gotop.Config, widRule widgetRule) interface{} {
var w interface{}
switch widRule.Widget {
case "cpu":

View File

@ -4,7 +4,7 @@ import (
"image"
"sort"
drawille "github.com/cjbassi/gotop/src/termui/drawille-go"
drawille "github.com/cjbassi/gotop/termui/drawille-go"
. "github.com/gizak/termui/v3"
)

View File

@ -9,7 +9,7 @@ import (
"github.com/distatus/battery"
ui "github.com/cjbassi/gotop/src/termui"
ui "github.com/cjbassi/gotop/termui"
)
type BatteryWidget struct {

View File

@ -8,7 +8,7 @@ import (
psCpu "github.com/shirou/gopsutil/cpu"
ui "github.com/cjbassi/gotop/src/termui"
ui "github.com/cjbassi/gotop/termui"
)
type CpuWidget struct {

View File

@ -9,8 +9,8 @@ import (
psDisk "github.com/shirou/gopsutil/disk"
ui "github.com/cjbassi/gotop/src/termui"
"github.com/cjbassi/gotop/src/utils"
ui "github.com/cjbassi/gotop/termui"
"github.com/cjbassi/gotop/utils"
)
type Partition struct {

View File

@ -7,8 +7,8 @@ import (
psMem "github.com/shirou/gopsutil/mem"
ui "github.com/cjbassi/gotop/src/termui"
"github.com/cjbassi/gotop/src/utils"
ui "github.com/cjbassi/gotop/termui"
"github.com/cjbassi/gotop/utils"
)
type MemWidget struct {

View File

@ -7,7 +7,7 @@ import (
"strconv"
"strings"
"github.com/cjbassi/gotop/src/utils"
"github.com/cjbassi/gotop/utils"
)
func convert(s []string) (MemoryInfo, error) {

View File

@ -7,8 +7,8 @@ import (
psNet "github.com/shirou/gopsutil/net"
ui "github.com/cjbassi/gotop/src/termui"
"github.com/cjbassi/gotop/src/utils"
ui "github.com/cjbassi/gotop/termui"
"github.com/cjbassi/gotop/utils"
)
const (

View File

@ -10,8 +10,8 @@ import (
psCPU "github.com/shirou/gopsutil/cpu"
ui "github.com/cjbassi/gotop/src/termui"
"github.com/cjbassi/gotop/src/utils"
ui "github.com/cjbassi/gotop/termui"
"github.com/cjbassi/gotop/utils"
)
const (

View File

@ -8,7 +8,7 @@ import (
"strconv"
"strings"
"github.com/cjbassi/gotop/src/utils"
"github.com/cjbassi/gotop/utils"
)
type processList struct {

View File

@ -9,7 +9,7 @@ import (
"strconv"
"strings"
"github.com/cjbassi/gotop/src/utils"
"github.com/cjbassi/gotop/utils"
)
const (

View File

@ -8,7 +8,7 @@ import (
ui "github.com/gizak/termui/v3"
"github.com/cjbassi/gotop/src/utils"
"github.com/cjbassi/gotop/utils"
)
type TempScale int

View File

@ -6,7 +6,7 @@ import "C"
import (
"log"
"github.com/cjbassi/gotop/src/utils"
"github.com/cjbassi/gotop/utils"
)
type TemperatureStat struct {

View File

@ -7,7 +7,7 @@ import (
"strconv"
"strings"
"github.com/cjbassi/gotop/src/utils"
"github.com/cjbassi/gotop/utils"
)
var sensorOIDS = map[string]string{

View File

@ -6,7 +6,7 @@ import (
psHost "github.com/shirou/gopsutil/host"
"github.com/cjbassi/gotop/src/utils"
"github.com/cjbassi/gotop/utils"
)
func (self *TempWidget) update() {

View File

@ -12,7 +12,7 @@ import (
"syscall"
"unsafe"
"github.com/cjbassi/gotop/src/utils"
"github.com/cjbassi/gotop/utils"
)
func (self *TempWidget) getTemp(mib []C.int, mlen int, snsrdev *C.struct_sensordev, index int) {

View File

@ -5,7 +5,7 @@ import (
psHost "github.com/shirou/gopsutil/host"
"github.com/cjbassi/gotop/src/utils"
"github.com/cjbassi/gotop/utils"
)
func (self *TempWidget) update() {