mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-06 10:22:50 +08:00
add headless mode
This commit is contained in:
4
Makefile
4
Makefile
@@ -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
|
||||
|
||||
20
app/main.go
20
app/main.go
@@ -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================")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
14
pkg/config/config_experimental.go
Normal file
14
pkg/config/config_experimental.go
Normal 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,
|
||||
}
|
||||
@@ -12,6 +12,7 @@ type _GeneralConfig struct {
|
||||
UseSystemPlaylist bool
|
||||
FixedSize bool
|
||||
EnableSMC bool // enable system media control
|
||||
|
||||
}
|
||||
|
||||
func (c *_GeneralConfig) Name() string {
|
||||
|
||||
Reference in New Issue
Block a user