diff --git a/src/focus.ts b/src/focus.ts index b84029f..0c6be80 100644 --- a/src/focus.ts +++ b/src/focus.ts @@ -151,6 +151,14 @@ function getMacOSActiveWindowId(): string | null { } function getMacOSFrontmostAppName(): string | null { + // Detect frontmost app regardless of activation policy + // (apps excluded from Dock and App Switcher) + const lsappinfo = execWithTimeout( + `lsappinfo info -only name \`lsappinfo front\` | sed 's/.*="\\([^"]*\\)".*/\\1/'` + ) + if (lsappinfo) return lsappinfo + + // Fallback to System Events if lsappinfo is unavailable return execWithTimeout( `osascript -e 'tell application "System Events" to return name of first application process whose frontmost is true'` )