add headless mode

This commit is contained in:
aynakeya
2024-11-12 16:59:36 -08:00
parent 97faa1a538
commit f36f56cd80
5 changed files with 35 additions and 6 deletions

View File

@@ -19,10 +19,10 @@ endif
bundle:
fyne bundle --name resImageIcon --package resource ./assets/icon.png > ./resource/bundle.go
# fyne bundle --append --name resFontMSYaHei --package resource ./assets/msyh.ttc >> ./resource/bundle.go
# fyne bundle --append --name resFontMSYaHeiBold --package resource ./assets/msyhbd.ttc >> ./resource/bundle.go
fyne bundle --append --name resFontMSYaHei --package resource ./assets/msyh0.ttf >> ./resource/bundle.go
fyne bundle --append --name resFontMSYaHeiBold --package resource ./assets/msyhbd0.ttf >> ./resource/bundle.go
# fyne bundle --append --name resFontMSYaHei --package resource ./assets/msyh.ttc >> ./resource/bundle.go
# fyne bundle --append --name resFontMSYaHeiBold --package resource ./assets/msyhbd.ttc >> ./resource/bundle.go
prebuild: bundle
$(RRM) ./release

View File

@@ -11,10 +11,13 @@ import (
"AynaLivePlayer/pkg/logger"
loggerRepo "AynaLivePlayer/pkg/logger/repository"
"flag"
"os"
"os/signal"
"time"
)
var dev = flag.Bool("dev", false, "dev")
var headless = flag.Bool("headless", false, "headless")
type _LogConfig struct {
config.BaseConfig
@@ -50,14 +53,20 @@ func main() {
global.Logger.Info("================Program Start================")
global.Logger.Infof("================Current Version: %s================", model.Version(config.Version))
internal.Initialize()
gui.Initialize()
go func() {
// temporary fix for gui not render correctly.
// wait until gui rendered then start event dispatching
time.Sleep(1 * time.Second)
global.EventManager.Start()
}()
gui.MainWindow.ShowAndRun()
if *headless || config.Experimental.Headless {
quit := make(chan os.Signal)
signal.Notify(quit, os.Interrupt)
<-quit
} else {
gui.Initialize()
gui.MainWindow.ShowAndRun()
}
global.Logger.Info("closing internal server")
internal.Stop()
global.Logger.Infof("closing event manager")
@@ -66,6 +75,11 @@ func main() {
global.Logger.Infof("saving translation")
i18n.SaveTranslation()
}
_ = config.SaveToConfigFile(config.ConfigPath)
err := config.SaveToConfigFile(config.ConfigPath)
if err != nil {
global.Logger.Errorf("save config failed: %v", err)
} else {
global.Logger.Infof("save config success")
}
global.Logger.Info("================Program End================")
}

View File

@@ -22,7 +22,7 @@ func GetAssetPath(name string) string {
return path.Join(AssetsPath, name)
}
var DEFAULT_CONFIGS = []Config{General}
var DEFAULT_CONFIGS = []Config{General, Experimental}
type Config interface {
Name() string

View File

@@ -0,0 +1,14 @@
package config
type _ExperimentalConfig struct {
BaseConfig
Headless bool
}
func (c *_ExperimentalConfig) Name() string {
return "Experimental"
}
var Experimental = &_ExperimentalConfig{
Headless: false,
}

View File

@@ -12,6 +12,7 @@ type _GeneralConfig struct {
UseSystemPlaylist bool
FixedSize bool
EnableSMC bool // enable system media control
}
func (c *_GeneralConfig) Name() string {