File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -174,10 +174,25 @@ def update() -> None:
174174 _tray .show ()
175175 app ._qt_tray = _tray
176176
177- _start_hidden = args .start_minimized_to_tray and _tray is not None
177+ # Hide the window when --start-minimized-to-tray is set, even if the system
178+ # tray is not ready yet (common at login time on macOS before the menu bar
179+ # is available). A retry timer creates the tray once it becomes available.
180+ _start_hidden = args .start_minimized_to_tray
178181 if not _start_hidden :
179182 window .show ()
180183
184+ if args .start_minimized_to_tray and _tray is None :
185+ def _retry_tray () -> None :
186+ if app ._qt_tray is not None : # type: ignore[attr-defined]
187+ return
188+ if QSystemTrayIcon .isSystemTrayAvailable ():
189+ tray = NetNeighborTray (app .windowIcon (), window , parent = app )
190+ tray .show ()
191+ app ._qt_tray = tray # type: ignore[attr-defined]
192+ else :
193+ QTimer .singleShot (2000 , _retry_tray )
194+ QTimer .singleShot (2000 , _retry_tray )
195+
181196 if sys .platform == "darwin" :
182197 # On macOS, clicking the Dock icon when the window is hidden fires
183198 # QEvent.Type.ApplicationActivate. Handle it so the window reappears
Original file line number Diff line number Diff line change @@ -169,6 +169,7 @@ def _macos_apply_autostart(enabled: bool) -> bool:
169169 f" <key>ProgramArguments</key>\n <array>\n { args_xml } \n </array>\n "
170170 " <key>RunAtLoad</key><true/>\n "
171171 " <key>KeepAlive</key><false/>\n "
172+ " <key>ProcessType</key><string>Background</string>\n "
172173 "</dict></plist>\n "
173174 )
174175 try :
You can’t perform that action at this time.
0 commit comments