mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-05-09 15:48:04 +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"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
window.present();
|
window.present();
|
||||||
|
|
||||||
// On macOS, surface the window on the specific launch that follows
|
// On macOS, default to presenting the main window on every launch
|
||||||
// the user clicking "Relaunch" after granting Accessibility, so
|
// so the user gets a visible confirmation that the app is running
|
||||||
// they see the app come up in its working state rather than just
|
// — including the post-grant relaunch and normal Dock/Finder/`open`
|
||||||
// a menu-bar icon and wonder whether anything happened.
|
// launches. Opt out by setting `LAN_MOUSE_HIDDEN=1` in the
|
||||||
// relaunch_bundle() sets LAN_MOUSE_RELAUNCHED=1 via `open --env`.
|
// 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")]
|
#[cfg(target_os = "macos")]
|
||||||
if env::var_os("LAN_MOUSE_RELAUNCHED").is_some() {
|
if env::var_os("LAN_MOUSE_HIDDEN").is_none() {
|
||||||
window.present();
|
window.present();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,11 +144,7 @@ pub fn relaunch_bundle() {
|
|||||||
|
|
||||||
// Trailing `&` backgrounds the sleep+open so our shell call returns
|
// Trailing `&` backgrounds the sleep+open so our shell call returns
|
||||||
// immediately; the spawned shell is adopted by launchd once we exit.
|
// immediately; the spawned shell is adopted by launchd once we exit.
|
||||||
// `--env LAN_MOUSE_RELAUNCHED=1` sets an env var on the new process
|
let cmd = format!("(sleep 1 && open {bundle:?}) &");
|
||||||
// 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 _ = Command::new("sh").arg("-c").arg(cmd).spawn();
|
let _ = Command::new("sh").arg("-c").arg(cmd).spawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user