Improved layout
This commit is contained in:
parent
f0d559ed64
commit
2452c88fd2
20
README.md
20
README.md
@ -2,28 +2,30 @@
|
|||||||
|
|
||||||
Dashboard for my terminal.
|
Dashboard for my terminal.
|
||||||
|
|
||||||
## Usage
|
## Examples
|
||||||
|
|
||||||
- Run your terminal in fullscreen
|
Transparent:
|
||||||
- Set the terminal opacity to 50%
|
|
||||||
- Start `dash`
|
![dash transparent](https://i.imgur.com/hc7tJYT.png)
|
||||||
|
|
||||||
|
Opaque:
|
||||||
|
|
||||||
|
![dash opaque](https://i.imgur.com/8rxHhDE.png)
|
||||||
|
|
||||||
## Config
|
## Config
|
||||||
|
|
||||||
The configuration is a normal text file living in `~/.config/dash/`.
|
The configuration is a normal text file living in `~/.config/dash/`.
|
||||||
|
|
||||||
You can use it to take notes or display the output of shell commands via the `{command args}` syntax.
|
You can use it to take plain old notes or display the output of shell commands via the `{command args}` syntax.
|
||||||
|
|
||||||
The output can be piped to other commands, e.g. `{pacman -Q | wc -l} packages installed`.
|
|
||||||
|
|
||||||
## Terminals
|
## Terminals
|
||||||
|
|
||||||
### alacritty
|
### alacritty
|
||||||
|
|
||||||
If you're using alacritty you can set the opacity for a single instance via:
|
You can set the opacity for a single window via:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
alacritty msg config window.opacity=0.5
|
alacritty msg config window.opacity=0.5
|
||||||
```
|
```
|
||||||
|
|
||||||
This will make your dashboard transparent but leaves the other windows at full transparency.
|
This will make your dashboard transparent but leaves the other windows at full opacity.
|
||||||
|
@ -7,26 +7,20 @@ import (
|
|||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
func New(format string, interval time.Duration) *tview.TextView {
|
||||||
interval = 1 * time.Second
|
|
||||||
format = "15:04:05"
|
|
||||||
)
|
|
||||||
|
|
||||||
func New(app *tview.Application) *tview.TextView {
|
|
||||||
view := tview.NewTextView()
|
view := tview.NewTextView()
|
||||||
view.SetTextAlign(tview.AlignCenter)
|
view.SetTextAlign(tview.AlignCenter)
|
||||||
view.SetBackgroundColor(tcell.ColorDefault)
|
view.SetBackgroundColor(tcell.ColorDefault)
|
||||||
view.SetText(time.Now().Format(format))
|
view.SetText(time.Now().Format(format))
|
||||||
view.SetBorderPadding(1, 1, 1, 1)
|
view.SetBorderPadding(1, 1, 1, 1)
|
||||||
go refresh(app, view)
|
go refresh(view, format, interval)
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
func refresh(app *tview.Application, view *tview.TextView) {
|
func refresh(view *tview.TextView, format string, interval time.Duration) {
|
||||||
tick := time.NewTicker(interval)
|
tick := time.NewTicker(interval)
|
||||||
|
|
||||||
for range tick.C {
|
for range tick.C {
|
||||||
view.SetText(time.Now().Format(format))
|
view.SetText(time.Now().Format(format))
|
||||||
app.Draw()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -21,7 +23,7 @@ func Process(source string) string {
|
|||||||
return err.Error()
|
return err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Trim(string(output), "\n")
|
return tview.TranslateANSI(strings.Trim(string(output), "\n"))
|
||||||
})
|
})
|
||||||
|
|
||||||
return source
|
return source
|
||||||
|
@ -16,7 +16,7 @@ type Editor struct {
|
|||||||
IsDirty bool
|
IsDirty bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(app *tview.Application, filePath string) *Editor {
|
func New(filePath string) *Editor {
|
||||||
e := &Editor{
|
e := &Editor{
|
||||||
FilePath: filePath,
|
FilePath: filePath,
|
||||||
}
|
}
|
||||||
|
13
empty/empty.go
Normal file
13
empty/empty.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package empty
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gdamore/tcell/v2"
|
||||||
|
"github.com/rivo/tview"
|
||||||
|
)
|
||||||
|
|
||||||
|
func New() *tview.Box {
|
||||||
|
view := tview.NewBox()
|
||||||
|
view.SetBackgroundColor(tcell.ColorDefault)
|
||||||
|
view.SetBorderPadding(1, 1, 1, 1)
|
||||||
|
return view
|
||||||
|
}
|
16
main.go
16
main.go
@ -3,11 +3,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.akyoto.dev/cli/dash/clock"
|
"git.akyoto.dev/cli/dash/clock"
|
||||||
"git.akyoto.dev/cli/dash/core"
|
"git.akyoto.dev/cli/dash/core"
|
||||||
"git.akyoto.dev/cli/dash/editor"
|
"git.akyoto.dev/cli/dash/editor"
|
||||||
"git.akyoto.dev/cli/dash/osinfo"
|
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
"github.com/rivo/tview"
|
"github.com/rivo/tview"
|
||||||
)
|
)
|
||||||
@ -28,9 +28,9 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
header := clock.New(app)
|
header := clock.New("15:04:05", time.Second)
|
||||||
main := editor.New(app, filepath.Join(dataDir, "main"))
|
main := editor.New(filepath.Join(dataDir, "main"))
|
||||||
footer := osinfo.New(app)
|
footer := clock.New("2006-01-02", time.Hour)
|
||||||
|
|
||||||
grid.AddItem(header, 0, 0, 1, 3, 0, 0, false)
|
grid.AddItem(header, 0, 0, 1, 3, 0, 0, false)
|
||||||
grid.AddItem(main.Pages, 1, 1, 1, 1, 0, 0, false)
|
grid.AddItem(main.Pages, 1, 1, 1, 1, 0, 0, false)
|
||||||
@ -40,6 +40,14 @@ func main() {
|
|||||||
app.SetRoot(grid, true)
|
app.SetRoot(grid, true)
|
||||||
app.SetFocus(main.Pages)
|
app.SetFocus(main.Pages)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
tick := time.NewTicker(time.Second)
|
||||||
|
|
||||||
|
for range tick.C {
|
||||||
|
app.Draw()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
err = app.Run()
|
err = app.Run()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
package osinfo
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os/exec"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gdamore/tcell/v2"
|
|
||||||
"github.com/rivo/tview"
|
|
||||||
)
|
|
||||||
|
|
||||||
func New(app *tview.Application) *tview.TextView {
|
|
||||||
view := tview.NewTextView()
|
|
||||||
view.SetTextAlign(tview.AlignCenter)
|
|
||||||
view.SetBackgroundColor(tcell.ColorDefault)
|
|
||||||
view.SetBorderPadding(1, 1, 1, 1)
|
|
||||||
|
|
||||||
out, _ := exec.Command("lsb_release", "-sd").Output()
|
|
||||||
distro := string(out)
|
|
||||||
distro = strings.TrimSpace(distro)
|
|
||||||
distro = strings.Trim(distro, "\"")
|
|
||||||
view.SetText(distro)
|
|
||||||
|
|
||||||
return view
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user