Skip to content

Commit

Permalink
consts colors
Browse files Browse the repository at this point in the history
  • Loading branch information
ghedamat committed Apr 21, 2014
1 parent 2ec7529 commit 01bf14f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions i3status/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ func (w *PowerWidget) getStatus() (string, string) {
bar := MakeBar(bi.PercentRemaining, 20)
remaining := HumanDuration(int64(bi.SecondsRemaining))
prefix := "BAT"
color := "#ffffff"
color := WHITE
if bi.IsCharging() {
prefix = "CHR"
color = GREEN
} else if bi.IsFull() {
prefix = "FULL"
} else {
if bi.PercentRemaining < 10 {
color = "#ff0000"
color = RED
} else if bi.PercentRemaining < 30 {
color = "#ffff00"
color = YELLOW
}
}
return fmt.Sprintf("%s %s %s %0.1f%%", prefix, remaining, bar, bi.PercentRemaining), color
Expand Down
7 changes: 7 additions & 0 deletions i3status/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import (
"os"
)

const (
RED = "#ff0000"
YELLOW = "#ffff00"
GREEN = "#00ff00"
WHITE = "#ffffff"
)

func ReadLines(fileName string, callback func(string) bool) {
fin, err := os.Open(fileName)
if err != nil {
Expand Down

0 comments on commit 01bf14f

Please sign in to comment.