summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bar.go21
-rw-r--r--main.go12
2 files changed, 25 insertions, 8 deletions
diff --git a/bar.go b/bar.go
new file mode 100644
index 0000000..5974ff4
--- /dev/null
+++ b/bar.go
@@ -0,0 +1,21 @@
+package main
+
+import "time"
+
+// Bar is the struct that holds each of the modules and displays the data from them
+type Bar struct {
+ Modules []Module
+ RefreshRate time.Duration
+}
+
+func (b Bar) Display() string {
+ var val string
+
+ for _, mod := range b.Modules {
+ s, _ := mod.GetInfo()
+ val += s
+ time.Sleep(b.RefreshRate)
+ }
+
+ return val
+}
diff --git a/main.go b/main.go
index dfaad2a..ef2df15 100644
--- a/main.go
+++ b/main.go
@@ -10,27 +10,23 @@ import (
"fmt"
// "os"
"os/exec"
- // "time"
+ "time"
)
-// Bar is the struct that holds each of the modules and displays the data from them
-type Bar struct {
- Modules []Module
-}
-
type Module interface {
GetInfo() (string, error)
}
+// Modules that are displayed in the bar
var BarModules = []Module{
DateModule{},
BatteryModule{},
}
func main() {
-
main := Bar{
- Modules: BarModules,
+ Modules: BarModules,
+ RefreshRate: time.Second * 1,
}
fmt.Println("Bar Started")