Merge pull request #671 from E1int/start-minimized-flag
Add CLI flag to start app minimized
This commit is contained in:
+3
-1
@@ -437,7 +437,7 @@ func (a *App) SetupWindowsSMTC(hwnd uintptr) {
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) LoginToDefaultServer(string) error {
|
||||
func (a *App) LoginToDefaultServer() error {
|
||||
serverCfg := a.ServerManager.GetDefaultServer()
|
||||
if serverCfg == nil {
|
||||
return ErrNoServers
|
||||
@@ -548,6 +548,8 @@ func (a *App) checkFlagsAndSendIPCMsg(cli *ipc.Client) error {
|
||||
return cli.SeekBackOrPrevious()
|
||||
case *FlagNext:
|
||||
return cli.SeekNext()
|
||||
case *FlagShow:
|
||||
return cli.Show()
|
||||
case VolumeCLIArg >= 0:
|
||||
return cli.SetVolume(VolumeCLIArg)
|
||||
case VolumePctCLIArg != 0:
|
||||
|
||||
@@ -17,6 +17,8 @@ var (
|
||||
FlagPlayPause = flag.Bool("play-pause", false, "toggle play/pause state")
|
||||
FlagPrevious = flag.Bool("previous", false, "seek to previous track or beginning of current")
|
||||
FlagNext = flag.Bool("next", false, "seek to next track")
|
||||
FlagStartMinimized = flag.Bool("start-minimized", false, "start app minimized")
|
||||
FlagShow = flag.Bool("show", false, "show minimized app")
|
||||
FlagVersion = flag.Bool("version", false, "print app version and exit")
|
||||
FlagHelp = flag.Bool("help", false, "print command line options and exit")
|
||||
)
|
||||
@@ -50,8 +52,11 @@ func init() {
|
||||
|
||||
func HaveCommandLineOptions() bool {
|
||||
visitedAny := false
|
||||
flag.Visit(func(*flag.Flag) {
|
||||
flag.Visit(func(f *flag.Flag) {
|
||||
// We skip `start-minimized` because it should't send an IPC message.
|
||||
if f.Name != "start-minimized" {
|
||||
visitedAny = true
|
||||
}
|
||||
})
|
||||
return visitedAny
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ func main() {
|
||||
defaultServer := myApp.ServerManager.GetDefaultServer()
|
||||
if defaultServer == nil {
|
||||
mainWindow.Controller.PromptForFirstServer()
|
||||
} else {
|
||||
} else if !*backend.FlagStartMinimized { // If the minimized start flag was passed, the connection is already established.
|
||||
mainWindow.Controller.DoConnectToServerWorkflow(defaultServer)
|
||||
}
|
||||
|
||||
@@ -103,7 +103,15 @@ func main() {
|
||||
})
|
||||
fyneApp.Lifecycle().SetOnEnteredForeground(windowStartupTasks)
|
||||
|
||||
if *backend.FlagStartMinimized {
|
||||
if err = myApp.LoginToDefaultServer(); err != nil {
|
||||
log.Fatalf("failed to connect to server: %v", err.Error())
|
||||
return
|
||||
}
|
||||
fyneApp.Run()
|
||||
} else {
|
||||
mainWindow.ShowAndRun()
|
||||
}
|
||||
|
||||
log.Println("Running shutdown tasks...")
|
||||
myApp.Shutdown()
|
||||
|
||||
Reference in New Issue
Block a user