Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show desktop immediatly at launch if already enabled #1911

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions cmd/launcher/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ func runDesktop(_ *multislogger.MultiSlogger, args []string) error {
"",
"path to icon file",
)
flDesktopEnabled = flagset.Bool(
"desktop_enabled",
false,
"if desktop already enabled, show desktop immediately",
)
)

if err := ff.Parse(flagset, args, ff.WithEnvVarNoPrefix()); err != nil {
Expand Down Expand Up @@ -127,7 +132,13 @@ func runDesktop(_ *multislogger.MultiSlogger, args []string) error {
}, func(error) {})

shutdownChan := make(chan struct{})
showDesktopChan := make(chan struct{})

// if desktop is not enabled, we will wait for a signal to show it
// on this channel
var showDesktopChan chan struct{}
if !*flDesktopEnabled {
showDesktopChan = make(chan struct{})
}

// Set up notification sending and listening
notifier := notify.NewDesktopNotifier(slogger, *flIconPath)
Expand Down Expand Up @@ -184,7 +195,11 @@ func runDesktop(_ *multislogger.MultiSlogger, args []string) error {
}
}()

<-showDesktopChan
// if desktop is not enabled at start up, wait for send on show desktop channel
if !*flDesktopEnabled {
<-showDesktopChan
}

// on darwin, if notifier.Listen() is called on a blocked main thread, it causes a crash,
// so we wait until the main thread is unblocked to call it before initializing the menu.
// this is noop for non-darwin
Expand Down
2 changes: 2 additions & 0 deletions ee/desktop/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,8 @@ func (r *DesktopUsersProcessesRunner) desktopCommand(executablePath, uid, socket
fmt.Sprintf("DEBUG=%v", r.knapsack.Debug()),
// needed for windows to find various allowed commands
fmt.Sprintf("WINDIR=%s", os.Getenv("WINDIR")),
// pass the desktop enabled flag so if it's already enabled, we show desktop immeadiately
fmt.Sprintf("DESKTOP_ENABLED=%v", r.knapsack.DesktopEnabled()),
"LAUNCHER_SKIP_UPDATES=true", // We already know that we want to run the version of launcher in `executablePath`, so there's no need to perform lookups
}

Expand Down
3 changes: 3 additions & 0 deletions ee/desktop/user/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func New(slogger *slog.Logger,
socketPath: socketPath,
notifier: notifier,
showDesktopOnceFunc: sync.OnceFunc(func() {
if showDesktopChan == nil {
return
}
showDesktopChan <- struct{}{}
}),
}
Expand Down
Loading