diff options
author | Jackson Taylor <jtaylormuffins@gmail.com> | 2020-04-11 12:10:32 -0400 |
---|---|---|
committer | Jackson Taylor <jtaylormuffins@gmail.com> | 2020-04-11 12:10:32 -0400 |
commit | feb0dfc20171ba5f0fe2b7defc3452744dd9e2d0 (patch) | |
tree | 0c8f07f408e3df539ad99af9cd2d7c8cd6111746 | |
parent | 203575b1f97501fd190bea67c11552f0635faa8d (diff) |
Change where loop occurs
Move the main program loop to main.go instead of in the bar itself
-rw-r--r-- | bar.go | 3 | ||||
-rw-r--r-- | main.go | 24 |
2 files changed, 6 insertions, 21 deletions
@@ -13,8 +13,7 @@ func (b Bar) Display() string { for _, mod := range b.Modules { s, _ := mod.GetInfo() - val += s - time.Sleep(b.RefreshRate) + val += "[" + s + "]" } return val @@ -8,11 +8,11 @@ package main import ( "fmt" - // "os" "os/exec" "time" ) +// Module is the interface for you to extend what your bar does. type Module interface { GetInfo() (string, error) } @@ -30,28 +30,14 @@ func main() { } fmt.Println("Bar Started") - var value string - for { - value = "" - for _, b := range main.Modules { - p1, err := b.GetInfo() - if err != nil { - fmt.Println(err) - continue - } - value += "[" + p1 + "]" - } - - setBar(value) + display(main.Display()) + time.Sleep(main.RefreshRate) + fmt.Println("Updating bar") } } -func getBattery() string { - return "100 %" -} - -func setBar(value string) (err error) { +func display(value string) (err error) { err = exec.Command("xsetroot", "-name", value).Run() return err } |