Flash time every 15 minutes

This commit is contained in:
akp 2025-01-12 20:47:05 +00:00
parent 74fbfc2cec
commit 1b5f4b35ce
No known key found for this signature in database
GPG key ID: CF8D58F3DEB20755
3 changed files with 12 additions and 4 deletions

View file

@ -13,6 +13,7 @@ type ColorSet struct {
Warning *Color
Good *Color
Background *Color
Foreground *Color
}
type Color struct {

View file

@ -58,6 +58,7 @@ var defaultColorSet = &ColorSet{
Bad: &Color{251, 73, 52},
Warning: &Color{250, 189, 47},
Background: &Color{0x28, 0x28, 0x28},
Foreground: &Color{0xbd, 0xae, 0x93},
}
func (b *I3bar) Emit(blocks []*Block) error {

View file

@ -7,7 +7,6 @@ import (
)
type DateTime struct {
// TODO: 12 hour mode?
name string
}
@ -21,14 +20,21 @@ func (g *DateTime) Frequency() uint8 {
return 1
}
func (g *DateTime) Block(*i3bar.ColorSet) (*i3bar.Block, error) {
func (g *DateTime) Block(cs *i3bar.ColorSet) (*i3bar.Block, error) {
cTime := time.Now().Local()
return &i3bar.Block{
block := &i3bar.Block{
Name: g.name,
FullText: cTime.Weekday().String()[:2] + cTime.Format(" 2006-01-02 15:04:05"),
ShortText: cTime.Format("15:04:05"),
}, nil
}
if (cTime.Minute() == 0 && cTime.Second() < 3) || (cTime.Minute() % 15 == 0 && cTime.Second() < 1) {
block.BackgroundColor = cs.Foreground
block.TextColor = cs.Background
}
return block, nil
}
func (g *DateTime) GetNameAndInstance() (string, string) {