Skip to content

Visible terminal flashes on Windows from focus-check PowerShell spawns #77

@mynameistito

Description

@mynameistito

Problem

On Windows, every focus check spawns a visible powershell.exe / pwsh.exe window that flashes on screen before closing.

Cause

src/focus.ts:101-106, getWindowsActiveWindowId() doesn't pass -WindowStyle Hidden:

let windowId = execFileWithTimeout("powershell", ["-NoProfile", "-NonInteractive", "-Command", script], 1000)
if (!windowId)
  windowId = execFileWithTimeout("pwsh", ["-NoProfile", "-NonInteractive", "-Command", script], 1000)

This runs on every notifier event. The PowerShell Operational log shows it firing every 10-30 seconds during active sessions.

Fix

Add "-WindowStyle", "Hidden" to both calls:

let windowId = execFileWithTimeout("powershell", ["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", script], 1000)
if (!windowId)
  windowId = execFileWithTimeout("pwsh", ["-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden", "-Command", script], 1000)

Tested locally. Same return value, no visible window.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions