Comments (6)
I think that'd be the best approach, although it'd be simpler if we change the bar's sync.Map
to a slice of blocks like this (which can be placed in config.go
), for example:
var blocks = []*Block{
&Block{
txt: "foo",
w: 10,
align: 'r',
xoff: 2,
bg: "#445967",
fg: "#CCCCCC",
actions: map[string]func() error{
"button1": func() error { return foo() },
"button2": func() error { return bar() },
},
},
&Block{
txt: "biz",
w: 15,
align: 'a',
xoff: 0,
bg: "#3C4F5B",
fg: "#CCCCCC",
actions: map[string]func() error{
"button1": func() error { return foo() },
"button2": func() error { return bar() },
},
},
}
which then each can be moved around and put together with a simpler initBlock
method and drawn when initializing the bar. foo()
and bar()
can be declared at the bottom of the file or maybe in a actions.go
file.
from melonbar.
it's just under a different name: https://github.com/onodera-punpun/melonbar/blob/master/blocks.go
from melonbar.
There are other such values (see: #1), I'll try creating something like this.
I'm still not sure what the best format would be, would individual blocks (their colors and such) also be configurable ins such a way?
from melonbar.
Furthermore should it be possible to disable entire blocks from this config file? Example, what if someone doesn't use mpd and wants to disable the music bar (#2).
from melonbar.
I've been working on something like this, an example of the "clock block":
blocks.Set("clock", &Block{
txt: "?",
w: 799,
align: 'a',
xoff: 0,
bg: xgraphics.BGRA{B: 103, G: 89, R: 68, A: 0xFF},
fg: xgraphics.BGRA{B: 204, G: 204, R: 204, A: 0xFF},
update: func() {
for {
block, _ := blocks.Get("clock")
block.(*Block).txt = time.Now().Format(
"Monday, January 2th 03:04 PM")
// Redraw the block.
bar.redraw <- block.(*Block)
// Update every 45 seconds.
time.Sleep(45 * time.Second)
}
},
})
from melonbar.
And there's still no config.go. Reality is cruel.
from melonbar.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from melonbar.