Add full threshold to battery
This commit is contained in:
parent
59289e3bff
commit
891906a049
3 changed files with 13 additions and 3 deletions
|
@ -25,7 +25,7 @@ func run() error {
|
|||
}
|
||||
|
||||
blocks := []i3bar.BlockGenerator{
|
||||
providers.NewBattery("BAT0", 30, 15),
|
||||
providers.NewBattery("BAT0", 80, 30, 20),
|
||||
providers.NewDisk("/", 30, 10),
|
||||
providers.NewCPU(20, 50),
|
||||
providers.NewMemory(7, 5),
|
||||
|
@ -56,5 +56,4 @@ func run() error {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Accept signals to refresh
|
||||
// TODO: Spotify provider!
|
||||
|
|
|
@ -29,6 +29,7 @@ func (b *I3bar) Initialise() error {
|
|||
}
|
||||
|
||||
var defaultColorSet = &ColorSet{
|
||||
Good: &Color{0xb8, 0xbb, 0x26},
|
||||
Bad: &Color{251, 73, 52},
|
||||
Warning: &Color{250, 189, 47},
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
)
|
||||
|
||||
type Battery struct {
|
||||
FullThreshold float32
|
||||
OkThreshold float32
|
||||
WarningThreshold float32
|
||||
|
||||
|
@ -18,9 +19,10 @@ type Battery struct {
|
|||
UseDesignMaxEnergy bool
|
||||
}
|
||||
|
||||
func NewBattery(name string, okThreshold, warningThreshold float32) i3bar.BlockGenerator {
|
||||
func NewBattery(name string, fullThreshold, okThreshold, warningThreshold float32) i3bar.BlockGenerator {
|
||||
return &Battery{
|
||||
Name: name,
|
||||
FullThreshold: fullThreshold,
|
||||
OkThreshold: okThreshold,
|
||||
WarningThreshold: warningThreshold,
|
||||
}
|
||||
|
@ -115,5 +117,13 @@ func (g *Battery) Block(colors *i3bar.ColorSet) (*i3bar.Block, error) {
|
|||
block.TextColor = colors.Warning
|
||||
}
|
||||
|
||||
if state == "CHR" {
|
||||
if percentage > g.FullThreshold && g.FullThreshold != 0 {
|
||||
block.TextColor = colors.Good
|
||||
} else {
|
||||
block.TextColor = nil // set to white
|
||||
}
|
||||
}
|
||||
|
||||
return block, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue