Skip to content

Commit

Permalink
use latest systray to hide until ready (kolide#1885)
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Pickett authored Oct 11, 2024
1 parent f0e70a5 commit 100a084
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
21 changes: 13 additions & 8 deletions cmd/launcher/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ func runDesktop(_ *multislogger.MultiSlogger, args []string) error {
return nil
}, func(error) {})

// Set up notification sending and listening
notifier := notify.NewDesktopNotifier(slogger, *flIconPath)
runGroup.Add("desktopNotifier", notifier.Listen, notifier.Interrupt)

// monitor parent
runGroup.Add("desktopMonitorParentProcess", func() error {
monitorParentProcess(slogger, *flRunnerServerUrl, *flRunnerServerAuthToken, 2*time.Second)
Expand All @@ -133,14 +129,14 @@ func runDesktop(_ *multislogger.MultiSlogger, args []string) error {
shutdownChan := make(chan struct{})
showDesktopChan := make(chan struct{})

// Set up notification sending and listening
notifier := notify.NewDesktopNotifier(slogger, *flIconPath)
server, err := userserver.New(slogger, *flUserServerAuthToken, *flUserServerSocketPath, shutdownChan, showDesktopChan, notifier)
if err != nil {
return err
}

universalLinkHandler, urlInput := universallink.NewUniversalLinkHandler(slogger)
runGroup.Add("universalLinkHandler", universalLinkHandler.Execute, universalLinkHandler.Interrupt)

// Pass through channel so that systray can alert the link handler when it receives a universal link request
m := menu.New(slogger, *flhostname, *flmenupath, urlInput)
refreshMenu := func() {
Expand Down Expand Up @@ -185,8 +181,17 @@ func runDesktop(_ *multislogger.MultiSlogger, args []string) error {
}
}()

// block until a send on showDesktopChan
<-showDesktopChan
go func() {
// wait to show desktop until we get the signal from root
<-showDesktopChan

// once desktop enabled, add notifier and universal link handler
runGroup.Add("universalLinkHandler", universalLinkHandler.Execute, universalLinkHandler.Interrupt)
runGroup.Add("desktopNotifier", notifier.Listen, notifier.Interrupt)

systray.Show()
}()

// blocks until shutdown called
m.Init()
return nil
Expand Down
4 changes: 4 additions & 0 deletions ee/desktop/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ func (r *DesktopUsersProcessesRunner) SendNotification(n notify.Notification) er
return errors.New("modern standby detected, skipping notification send")
}

if !r.knapsack.DesktopEnabled() {
return errors.New("desktop is not enabled, cannot send notification")
}

if len(r.uidProcs) == 0 {
return errors.New("cannot send notification, no child desktop processes")
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ require (
github.com/golang-migrate/migrate/v4 v4.16.2
github.com/golang/snappy v0.0.4
github.com/kolide/goleveldb v0.0.0-20240514204455-8d30cd4d31c6
github.com/kolide/systray v0.0.0-20240530130728-8265cd4e35db
github.com/kolide/systray v1.10.5-0.20241011144003-35bc09a9664f
github.com/kolide/toast v1.0.2
github.com/shirou/gopsutil/v3 v3.23.3
github.com/spf13/pflag v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ github.com/kolide/kit v0.0.0-20240411131714-94dd1939cf50 h1:N7RaYBPTK5o4y2z1z8kl
github.com/kolide/kit v0.0.0-20240411131714-94dd1939cf50/go.mod h1:pFbEKXFww1uqu4RRO7qCnUmQ2EIwKYRzUqpJbODNlfc=
github.com/kolide/krypto v0.1.1-0.20231229162826-db516b7e0121 h1:f7APX9VNsCkD/tdlAjbU4A22FyfTOCF6QadlvnzZElg=
github.com/kolide/krypto v0.1.1-0.20231229162826-db516b7e0121/go.mod h1:/0sxd3OIxciTlMTeZI/9WTaUHsx/K/+3f+NbD5dywTY=
github.com/kolide/systray v0.0.0-20240530130728-8265cd4e35db h1:bOEgeG+7TOrK8ZOwXP49W1OKFfUWrWnXc7jstFRNDbQ=
github.com/kolide/systray v0.0.0-20240530130728-8265cd4e35db/go.mod h1:FwK9yUmU3JO+vA7TOLQSFRgEQ3euLxOqic5qlBtFrik=
github.com/kolide/systray v1.10.5-0.20241011144003-35bc09a9664f h1:v3y9fZGNWLyX21t4Oh0J/mR0AUD2IT8XdSMEz7727+w=
github.com/kolide/systray v1.10.5-0.20241011144003-35bc09a9664f/go.mod h1:FwK9yUmU3JO+vA7TOLQSFRgEQ3euLxOqic5qlBtFrik=
github.com/kolide/toast v1.0.2 h1:BQlIfO3wbKIEWfF0c8v4UkdhSIZYnSWaKkZl+Yarptk=
github.com/kolide/toast v1.0.2/go.mod h1:OguLiOUf57YSEuZqjfk4uP4KdT0QOblGoySOI8F1I0Y=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
Expand Down

0 comments on commit 100a084

Please sign in to comment.