From d70fe40f9de2a10ccd5892b7886a559b181748cc Mon Sep 17 00:00:00 2001 From: Jackson Taylor Date: Tue, 31 Mar 2020 22:35:25 -0400 Subject: Add initial files for status bar Add main function loop Add a battery module for laptops Add a date module --- main.go | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 main.go (limited to 'main.go') diff --git a/main.go b/main.go new file mode 100644 index 0000000..dfaad2a --- /dev/null +++ b/main.go @@ -0,0 +1,61 @@ +package main + +/* + Author: Jackson Taylor + Date: 3/28/2020 + Description: This is Jackson's Awesome Status Bar for suckless', very nice, dwm. +*/ + +import ( + "fmt" + // "os" + "os/exec" + // "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) +} + +var BarModules = []Module{ + DateModule{}, + BatteryModule{}, +} + +func main() { + + main := Bar{ + Modules: BarModules, + } + 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) + } +} + +func getBattery() string { + return "100 %" +} + +func setBar(value string) (err error) { + err = exec.Command("xsetroot", "-name", value).Run() + return err +} -- cgit v1.2.3