barster
is a content provider for simple, string based status-bars like
dwm's bar, or wayland statusbar projects like
sewn/dam. Essentially, barster
continually
outputs the content of a statusbar as a single string that is then displayed on
the bar.
With dwm
you would use barster
like this:
barster | while read new_status; do xsetroot -name "$new_status"; done
With dam
you would use `barster like this:
barster | dam
- The final output is composed of individual "modules".
- Collection of prebuilt modules like Battery, Datetime, Nettraffic, ...
- Easy to add new custom modules tailored to your system.
- Modules can update independently on a timer (polling), or even only when their data changes (event-driven) for optimal performance.
First, make sure you have go installed.
git clone https://github.com/wintermute-cell/barster
cd barster
go build
./barster
To configure, modify main.go
and recompile using go build
. The
prebuilt directory contains a (growing) number of prebuilt
modules. To add a new module, add it to the modules
list in main.go
:
modules := []pkg.Module{
// Put the modules here!
}
The easiest way to create a custom module is to add a block like this to the modules
list in main.go
:
modules := []pkg.Module{
{
Name: "myModule", // has to be unique across modules
Interval: 1 * time.Second, // the module will update every second
Update: func() string { // the function that returns the module's output
return "Hello, world! Random number: " + fmt.Sprint(rand.Intn(100))
},
},
// Other modules ...
}
You should be comfortable with goroutines
before attempting this!
To save on cpu time, you can set up modules to only re-run when the module
itself wants to. To do this, set the Interval
to a really high value, and add
a Ticker
:
modules := []pkg.Module{
{
Name: "eventDrivenModule",
Interval: 1000 * time.Hour, // effectively disables periodic updates
Update: func() string {
return "Hello World!"
},
// the ticker is a channel that notifies the
// statusbar that the module needs to update.
Ticker: func() chan struct{} {
ch := make(chan struct{})
go func() {
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
for {
<-ticker.C
ch <- struct{}{}
}
}()
return ch
}(),
},
// Other modules ...
}
You are welcome to contribute new modules you've built! Please make sure they are as portable as they can be so many people can benefit.
You may also create feature request issues if you are unable to create a module you need yourself.