Skip to content

Commit 3b8c5bb

Browse files
committed
Fix for OSX start session
Fix to remove end session message
1 parent 8bc3867 commit 3b8c5bb

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎app/app_qt.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff 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

‎app/utils/session_autostart.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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:

0 commit comments

Comments
 (0)