aerc/cmd/aerc/main.go

45 lines
857 B
Go
Raw Normal View History

2018-01-10 00:30:46 +01:00
package main
import (
2018-01-10 14:35:26 +01:00
"time"
2018-01-10 01:18:19 +01:00
"git.sr.ht/~sircmpwn/aerc2/config"
2018-01-11 04:03:56 +01:00
"git.sr.ht/~sircmpwn/aerc2/ui"
"git.sr.ht/~sircmpwn/aerc2/worker"
"git.sr.ht/~sircmpwn/aerc2/worker/types"
2018-01-10 00:30:46 +01:00
)
func main() {
2018-01-10 17:19:45 +01:00
conf, err := config.LoadConfig(nil)
if err != nil {
2018-01-10 01:18:19 +01:00
panic(err)
}
2018-01-10 17:19:45 +01:00
var workers []worker.Worker
2018-01-10 03:24:50 +01:00
for _, account := range conf.Accounts {
2018-01-10 17:19:45 +01:00
work, err := worker.NewWorker(account.Source)
if err != nil {
2018-01-10 03:24:50 +01:00
panic(err)
}
go work.Run()
work.PostAction(types.Configure{Config: account})
workers = append(workers, work)
}
2018-01-11 04:03:56 +01:00
_ui, err := ui.Initialize(conf)
if err != nil {
panic(err)
}
defer _ui.Close()
for !_ui.Exit {
2018-01-10 14:35:26 +01:00
activity := false
2018-01-10 03:24:50 +01:00
for _, worker := range workers {
if msg := worker.GetMessage(); msg != nil {
2018-01-10 14:35:26 +01:00
activity = true
2018-01-10 03:24:50 +01:00
}
}
2018-01-11 04:03:56 +01:00
activity = _ui.Tick() || activity
2018-01-10 14:35:26 +01:00
if !activity {
time.Sleep(100 * time.Millisecond)
}
}
2018-01-10 00:30:46 +01:00
}