mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-05-07 22:58:05 +03:00
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) <noreply@anthropic.com>
This commit is contained in:
committed by
Ferdinand Schober
parent
99344a3104
commit
10fd728804
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user