Skip to content

Windows: Add close-to-tray support (keep running in background when console closes) - #72

Open
edmonbpb wants to merge 8 commits into
CluvexStudio:mainfrom
edmonbpb:close-to-tray-windows
Open

Windows: Add close-to-tray support (keep running in background when console closes)#72
edmonbpb wants to merge 8 commits into
CluvexStudio:mainfrom
edmonbpb:close-to-tray-windows

Conversation

@edmonbpb

@edmonbpb edmonbpb commented Aug 1, 2026

Copy link
Copy Markdown

Summary

Adds "close-to-tray" functionality for the Windows build. When the user closes the console window (clicking the X button), Aether detaches from the console and continues running the tunnel in the background. A system tray icon appears with an "Exit" menu item for clean shutdown.

How it works

  • Registers a console Ctrl handler via exttt{SetConsoleCtrlHandler} that intercepts exttt{CTRL_CLOSE_EVENT}, exttt{CTRL_LOGOFF_EVENT}, and exttt{CTRL_SHUTDOWN_EVENT}.
  • On these events, calls exttt{FreeConsole()} to detach from the console, preventing the ~5s force-termination.
  • Creates a system tray icon using the exttt{tray-icon} crate (with exttt{common-controls-v6} for proper Windows 10/11 menu rendering) that provides an "Exit" item to cleanly terminate the process.

Platform & dependencies

  • Windows-only ( exttt{[cfg(target_os = "windows")]}).
  • New Windows-only dependencies under exttt{[target.'cfg(windows)'.dependencies]}:
    • exttt{tray-icon = "0.24"} (with 	exttt{common-controls-v6} feature)
      
    • No new cross-platform dependencies.

Configuration

  • Enabled by default on Windows.
  • Disable with environment variable exttt{AETHER_CLOSE_TO_TRAY=0} (or exttt{false}, exttt{off}, exttt{no}).

Testing

  • Verified compilation on Windows with the MSVC toolchain ( exttt{cargo check} passes for the new tray module).
  • The GitHub Actions CI ( exttt{release.yml}) will run the full Windows build on exttt{windows-latest} runners to verify the complete build.

Notes

  • The console handler explicitly does NOT handle exttt{CTRL_C_EVENT} or exttt{CTRL_BREAK_EVENT}, preserving the default Ctrl+C behavior (immediate exit).
  • The exttt{Cargo.lock} has been updated with the new exttt{tray-icon} dependency and its transitive dependencies.

Fixes the issue of Aether exiting completely when the console window is closed on Windows.

Psiphon Iran Custom Build added 8 commits August 1, 2026 04:22
On Windows, clicking the console window's close (X) button now keeps
Aether running in the background instead of exiting. A tray icon with
an Exit item appears in the notification area. The feature is enabled
by default on Windows; set AETHER_CLOSE_TO_TRAY=0 to restore the old
close-to-exit behavior.

- New tray.rs module (Windows-only) with console Ctrl handler + tray icon
- Windows-only tray-icon dependency (0.24, common-controls-v6)
- Updated README.md and README.fa.md with feature docs
- Updated Cargo.lock with tray-icon dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant