Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'`
)
Expand Down