Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.

Commit

Permalink
Fix inconsistent cpu color order
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbassi committed Aug 17, 2018
1 parent c3603ea commit fc56114
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/signal"
"sort"
"strconv"
"sync"
"syscall"
Expand Down Expand Up @@ -181,14 +182,19 @@ func widgetColors() {
mem.LineColor["Main"] = ui.Color(colorscheme.MainMem)
mem.LineColor["Swap"] = ui.Color(colorscheme.SwapMem)

var keys []string
for key := range cpu.Data {
keys = append(keys, key)
}
sort.Strings(keys)
i := 0
for k := range cpu.Data {
for _, v := range keys {
if i >= len(colorscheme.CPULines) {
// assuming colorscheme for CPU lines is not empty
i = 0
}
c := colorscheme.CPULines[i]
cpu.LineColor[k] = ui.Color(c)
cpu.LineColor[v] = ui.Color(c)
i++
}

Expand Down

0 comments on commit fc56114

Please sign in to comment.