mirror of
https://github.com/fleetdm/fleet
synced 2026-05-12 19:48:45 +00:00
For #25616 # Checklist for submitter - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - For Orbit and Fleet Desktop changes: - [X] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - Tested on macOS, Windows, Ubuntu, Fedora (w/ and without system tray) and Debian (w/ and without system tray) ## Details This PR addresses the issue that on Ubuntu, if a user restarts their display manager (e.g. with `sudo systemctl restart gdm3`), the Fleet Desktop tray icon disappears and doesn't come back. The solution in this PR is to add a function that runs in a loop and checks whether the tray icon still exists, and if not, kills the Fleet Desktop process. The parent Orbit process already has code to restart the desktop if it dies. We also update the Orbit checker to run every 15 seconds, to limit the delay in the icon coming back after a restart. Also included in this PR is a rename from `desktop_unix.go` to `desktop_linux.go`, which will be used automatically for linux builds, and a new `desktop_darwin.go` for macos builds, and the removal of redundant build directives for all.
34 lines
810 B
Go
34 lines
810 B
Go
package main
|
|
|
|
import (
|
|
_ "embed"
|
|
"fmt"
|
|
"os"
|
|
"slices"
|
|
|
|
"github.com/godbus/dbus/v5"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
//go:embed icon_dark.png
|
|
var iconDark []byte
|
|
|
|
func blockWaitForStopEvent(_ string) error {
|
|
log.Debug().Msg("communication channel helpers are not implemented for this platform")
|
|
return nil
|
|
}
|
|
|
|
func trayIconExists() bool {
|
|
conn, err := dbus.SessionBus()
|
|
if err != nil {
|
|
log.Error().Err(err)
|
|
}
|
|
|
|
// Get the name we would expect systray to reserve for our tray icon.
|
|
trayIconDbusName := fmt.Sprintf("org.kde.StatusNotifierItem-%d-1", os.Getpid())
|
|
// Get the names this session currently owns.
|
|
ownedDbusNames := conn.Names()
|
|
// If the tray icon name isn't in the list, it likely means the tray icon is
|
|
// no longer visible.
|
|
return slices.Contains(ownedDbusNames, trayIconDbusName)
|
|
}
|