2017-07-11 01:17:27 +00:00
|
|
|
[![Go Report Card](https://goreportcard.com/badge/github.com/onodera-punpun/melonbar)](https://goreportcard.com/report/github.com/onodera-punpun/melonbar)
|
|
|
|
|
2017-07-11 15:25:19 +00:00
|
|
|
melonbar - A concurrent, hackable bar/panel for X written in Go.
|
2017-07-11 01:17:27 +00:00
|
|
|
|
2017-07-13 18:57:42 +00:00
|
|
|
![](https://punpun.xyz/54c7.png)
|
|
|
|
|
2017-07-11 01:17:27 +00:00
|
|
|
|
|
|
|
## INSTALLATION
|
|
|
|
|
|
|
|
`go get github.com/onodera-punpun/melonbar`
|
|
|
|
|
2017-07-11 15:25:19 +00:00
|
|
|
`melonbar` depends on Go 1.9 or newer.
|
|
|
|
|
|
|
|
|
|
|
|
## USAGE
|
|
|
|
|
2018-12-26 01:00:32 +00:00
|
|
|
The idea is that this bar is very "simple" to configure by just modifying the
|
|
|
|
source code, à la suckless.
|
2017-07-11 15:25:19 +00:00
|
|
|
|
2018-12-26 01:00:32 +00:00
|
|
|
Users can configure the position, width, height and font of the bar in
|
|
|
|
`main.go`. A bar consist of various blocks that display info, these blocks are
|
|
|
|
functions definded in `blocks.go` and exectured in a goroutine in `main.go`.
|
2017-07-11 15:25:19 +00:00
|
|
|
|
|
|
|
|
2017-07-11 19:58:23 +00:00
|
|
|
## CREATING BLOCK FUNCTIONS
|
2017-07-11 15:25:19 +00:00
|
|
|
|
2018-12-26 01:00:32 +00:00
|
|
|
On top of each block function you should run `bar.initBlock()`, this generates a
|
|
|
|
block object, and is where most of the configuration happens. Here is a short
|
2017-07-11 15:25:19 +00:00
|
|
|
explanation of each parameter from left to right:
|
|
|
|
|
2018-12-26 01:00:32 +00:00
|
|
|
* The name of the block, this is gets used as the name of the block map key.
|
|
|
|
(`string`)
|
2017-07-11 15:25:19 +00:00
|
|
|
* The initial string the block should display. (`string`)
|
|
|
|
* The width of the block. (`int`)
|
2018-12-26 01:00:32 +00:00
|
|
|
* The aligment of the text, this can be `'l'` for left aligment, `'c'` for
|
|
|
|
center aligment `'r'` for right aligment and `'a'` for absolute center
|
|
|
|
aligment. (`rune`)
|
|
|
|
* Additional x offset to further tweak the location of the text. (`int`)
|
2017-07-11 15:25:19 +00:00
|
|
|
* The foreground color of the block in hexadecimal. (`string`)
|
|
|
|
* The background color of the block in hexadecimal. (`string`)
|
|
|
|
|
2018-12-26 01:00:32 +00:00
|
|
|
It is possible to bind mousebindings to a block using using:
|
2017-07-13 18:51:08 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
block.actions["buttonN"] = func() {
|
|
|
|
// Do stuff.
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2017-07-11 15:25:19 +00:00
|
|
|
---
|
|
|
|
|
2018-12-26 01:00:32 +00:00
|
|
|
When you've gathered all information you can update the block values using for
|
|
|
|
example `block.bg = "#FF0000"` or `block.txt = "Hello World!"` and executing
|
2017-07-13 18:51:08 +00:00
|
|
|
`bar.redraw <- block`.
|
|
|
|
|
|
|
|
|
|
|
|
## TODO
|
|
|
|
|
|
|
|
* Create some kind of easy to use init function for blocks (instead of
|
|
|
|
the `if !init` stuff I use at the moment).
|
|
|
|
* Add popups.
|
2017-07-11 15:25:19 +00:00
|
|
|
|
2017-07-11 01:17:27 +00:00
|
|
|
|
|
|
|
## AUTHORS
|
|
|
|
|
|
|
|
Camille Scholtz
|