Update readme

This commit is contained in:
Camille Scholtz 2018-12-26 02:00:32 +01:00
parent 449b00905c
commit 874e54d240

@ -14,32 +14,32 @@ melonbar - A concurrent, hackable bar/panel for X written in Go.
## USAGE ## USAGE
So the idea is that this bar is very "easy" to configure by just The idea is that this bar is very "simple" to configure by just modifying the
modifying the source code, à la suckless. source code, à la suckless.
Users can modify, configure and create new "blocks" in `blocks.go`. Users can configure the position, width, height and font of the bar in
and configure the position, width and font of the bar in `main.go`. `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`.
## CREATING BLOCK FUNCTIONS ## CREATING BLOCK FUNCTIONS
On top of each block function you should run `bar.initBlock()`, this On top of each block function you should run `bar.initBlock()`, this generates a
is where most of the configuration happens. Here is a short block object, and is where most of the configuration happens. Here is a short
explanation of each parameter from left to right: explanation of each parameter from left to right:
* The name of the block, this is gets used as the name of the block * The name of the block, this is gets used as the name of the block map key.
map key. (`string`) (`string`)
* The initial string the block should display. (`string`) * The initial string the block should display. (`string`)
* The width of the block. (`int`) * The width of the block. (`int`)
* The aligment of the text, this can be `'l'` for left aligment, `'c'` * The aligment of the text, this can be `'l'` for left aligment, `'c'` for
for center aligment `'r'` for right aligment and `'a'` for absolute center aligment `'r'` for right aligment and `'a'` for absolute center
center aligment. (`rune`) aligment. (`rune`)
* Additional x offset to further tweak the location of the text. * Additional x offset to further tweak the location of the text. (`int`)
(`int`)
* The foreground color of the block in hexadecimal. (`string`) * The foreground color of the block in hexadecimal. (`string`)
* The background color of the block in hexadecimal. (`string`) * The background color of the block in hexadecimal. (`string`)
You can also additionally specify mousebindings using: It is possible to bind mousebindings to a block using using:
```go ```go
block.actions["buttonN"] = func() { block.actions["buttonN"] = func() {
@ -47,36 +47,10 @@ block.actions["buttonN"] = func() {
} }
``` ```
--- ---
Everything that should not be ran in a loop should of course be When you've gathered all information you can update the block values using for
specified before the `for` loop. For example setting up a connection example `block.bg = "#FF0000"` or `block.txt = "Hello World!"` and executing
to `mpd`.
If you want something to only be done *after* the very first loop - an
example of this would be not waiting for a workspace change event, but
immediately checking the current workspace - use:
```go
init := true
for {
if !init {
// Things you only want to do after the first loop.
}
init = false
...
```
This can be helpful because else the bar would display `"?"` before
the user changes his workspace for the first time.
---
When you've gathered all information you can update the block values
using for example `block.bg = value` and running
`bar.redraw <- block`. `bar.redraw <- block`.
@ -85,10 +59,6 @@ using for example `block.bg = value` and running
* Create some kind of easy to use init function for blocks (instead of * Create some kind of easy to use init function for blocks (instead of
the `if !init` stuff I use at the moment). the `if !init` stuff I use at the moment).
* Add popups. * Add popups.
* Drop support for `ttf` fonts and use `pcf` fonts instead if
possible.
* or maybe some kind of different format altogether that's easily
hackable, such as suckless farbfeld?
## AUTHORS ## AUTHORS