2017-10-15 09:41:36 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/BurntSushi/toml"
|
2017-11-04 22:02:12 +01:00
|
|
|
tm "github.com/buger/goterm"
|
2017-10-15 09:41:36 +02:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"statusscreen"
|
2017-11-04 14:36:01 +01:00
|
|
|
"time"
|
2017-10-15 09:41:36 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
config := getConfig("status.toml")
|
|
|
|
|
2017-11-04 10:37:59 +01:00
|
|
|
sl := statusscreen.SL{Config: &config}
|
2017-11-04 14:36:01 +01:00
|
|
|
clock := statusscreen.Clock{Config: &config}
|
|
|
|
weather := statusscreen.Weather{Config: &config}
|
|
|
|
|
2017-11-04 22:02:12 +01:00
|
|
|
tm.Clear()
|
2017-11-04 22:09:53 +01:00
|
|
|
tm.Print("\033[?25l")
|
2017-11-04 22:02:12 +01:00
|
|
|
|
2017-11-04 14:36:01 +01:00
|
|
|
for {
|
2017-11-04 22:02:12 +01:00
|
|
|
tm.MoveCursor(1, 1)
|
|
|
|
|
2017-11-04 14:36:01 +01:00
|
|
|
for _, row := range clock.GetOutput() {
|
2017-11-04 22:02:12 +01:00
|
|
|
tm.Print(row + "\033[K\n")
|
2017-11-04 14:36:01 +01:00
|
|
|
}
|
2017-11-04 22:02:12 +01:00
|
|
|
|
|
|
|
tm.Print("\033[K\n")
|
|
|
|
|
2017-11-04 14:36:01 +01:00
|
|
|
for _, row := range weather.GetOutput() {
|
2017-11-04 22:02:12 +01:00
|
|
|
tm.Print(row + "\033[K\n")
|
2017-11-04 14:36:01 +01:00
|
|
|
}
|
2017-11-04 22:02:12 +01:00
|
|
|
|
|
|
|
tm.Print("\033[K\n")
|
|
|
|
|
2017-11-04 14:36:01 +01:00
|
|
|
for _, row := range sl.GetOutput() {
|
2017-11-04 22:02:12 +01:00
|
|
|
tm.Print(row + "\033[K\n")
|
2017-11-04 14:36:01 +01:00
|
|
|
}
|
|
|
|
|
2017-11-04 22:02:12 +01:00
|
|
|
tm.Flush()
|
|
|
|
|
2017-11-04 22:09:53 +01:00
|
|
|
time.Sleep(time.Second / 10)
|
2017-11-04 14:36:01 +01:00
|
|
|
}
|
2017-10-15 09:41:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|