You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
statusscreen/statusscreen.go

65 lines
1.1 KiB

package main
import (
"fmt"
"github.com/BurntSushi/toml"
tm "github.com/buger/goterm"
"io/ioutil"
"os"
"statusscreen"
"time"
)
func main() {
config := getConfig("status.toml")
sl := statusscreen.SL{Config: &config}
clock := statusscreen.Clock{Config: &config}
weather := statusscreen.Weather{Config: &config}
tm.Clear()
tm.Print("\033[?25l")
for {
tm.MoveCursor(1, 1)
for _, row := range clock.GetOutput() {
tm.Print(row + "\033[K\n")
}
tm.Print("\033[K\n")
for _, row := range weather.GetOutput() {
tm.Print(row + "\033[K\n")
}
tm.Print("\033[K\n")
for _, row := range sl.GetOutput() {
tm.Print(row + "\033[K\n")
}
tm.Flush()
time.Sleep(time.Second / 10)
}
}
func getConfig(configFile string) statusscreen.Config {
var config statusscreen.Config
// Read the configfile
file, err := ioutil.ReadFile(configFile)
if err != nil {
fmt.Printf("File error: %v\n", err)
os.Exit(1)
}
// Parse config
if _, err := toml.Decode(string(file), &config); err != nil {
fmt.Printf("Config error: %v\n", err)
os.Exit(1)
}
return config
}