From 10fd7288044e2ab27d8af6805edfd374526690cf Mon Sep 17 00:00:00 2001 From: Jon Kinney Date: Fri, 24 Apr 2026 10:45:24 -0500 Subject: [PATCH] macos: default to showing the window on every launch Replaces the narrow LAN_MOUSE_RELAUNCHED signal with an inverted opt-out: present the main window on every macOS launch unless LAN_MOUSE_HIDDEN=1 is in the environment. User feedback: on any manual launch (Dock, Finder, `open`, post- grant relaunch) the window should come up so the user has a visible confirmation the app is alive and can see its current state. A hidden-to-menu-bar-only launch should be opt-in for a LaunchAgent / login-item configuration, not the default. LaunchAgent plists can set the env via `EnvironmentVariables` and `RunAtLoad=true` for a quiet boot launch. Co-Authored-By: Claude Opus 4.7 (1M context) --- lan-mouse-gtk/src/lib.rs | 14 ++++++++------ lan-mouse-gtk/src/macos_privacy.rs | 6 +----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lan-mouse-gtk/src/lib.rs b/lan-mouse-gtk/src/lib.rs index c1acbd4..112feba 100644 --- a/lan-mouse-gtk/src/lib.rs +++ b/lan-mouse-gtk/src/lib.rs @@ -279,13 +279,15 @@ fn build_ui(app: &Application) { #[cfg(not(target_os = "macos"))] window.present(); - // On macOS, surface the window on the specific launch that follows - // the user clicking "Relaunch" after granting Accessibility, so - // they see the app come up in its working state rather than just - // a menu-bar icon and wonder whether anything happened. - // relaunch_bundle() sets LAN_MOUSE_RELAUNCHED=1 via `open --env`. + // On macOS, default to presenting the main window on every launch + // so the user gets a visible confirmation that the app is running + // — including the post-grant relaunch and normal Dock/Finder/`open` + // launches. Opt out by setting `LAN_MOUSE_HIDDEN=1` in the + // environment (useful for a LaunchAgent / login-item configuration + // where the user wants the app to come up quietly into the menu + // bar only, with no window on boot). #[cfg(target_os = "macos")] - if env::var_os("LAN_MOUSE_RELAUNCHED").is_some() { + if env::var_os("LAN_MOUSE_HIDDEN").is_none() { window.present(); } } diff --git a/lan-mouse-gtk/src/macos_privacy.rs b/lan-mouse-gtk/src/macos_privacy.rs index 3d93667..9183a96 100644 --- a/lan-mouse-gtk/src/macos_privacy.rs +++ b/lan-mouse-gtk/src/macos_privacy.rs @@ -144,11 +144,7 @@ pub fn relaunch_bundle() { // Trailing `&` backgrounds the sleep+open so our shell call returns // immediately; the spawned shell is adopted by launchd once we exit. - // `--env LAN_MOUSE_RELAUNCHED=1` sets an env var on the new process - // so `build_ui` can present the main window on this specific launch - // (confirming to the user that the grant + relaunch worked) while - // still starting hidden in the menu bar on normal fresh launches. - let cmd = format!("(sleep 1 && open --env LAN_MOUSE_RELAUNCHED=1 {bundle:?}) &"); + let cmd = format!("(sleep 1 && open {bundle:?}) &"); let _ = Command::new("sh").arg("-c").arg(cmd).spawn(); }