Detecting Safari PWA windows in Hammerspoon

I spent more time than I want to admit trying to figure out why my Hammerspoon config wasn’t catching new Safari PWA windows opened via links using Right Click > Open in New Window. So I thought a solution needed to be shared.

My Hammerspoon setup watches for windowCreated events and auto-centers new standard windows (non-standard windows would be windows like modals, file dialogs, etc) using this logic:

if false == win:isStandard() then return end

This check is critical, it prevents centering things like sheets, popups, and tooltips from being centered (they already are). But it also didn’t work for windows opened this specific way. At first, I thought it was some weird quirk or race condition. Nope.

Turns out win:isStandard() returns false for Safari PWA windows opened this way, even though they look and act like normal app windows. Even if you open a new Window via File > New Window, win:isStandard() is true, but windows opened via the context menu don’t…I guess?

I started logging more aggressively. Specifically, I dumped win:application():bundleID() for all windows, standard or not. That’s when I saw this for my PWA application: com.apple.Safari.WebApp.A1B2C3D4...

That’s the bundle ID the PWA (WebApp) uses. 

The Fix

I updated my check to this:

if false == win:isStandard() or win:application():bundleID():find( "Safari.WebApp" )

Hope it helps someone…

August 14, 2025

Re: Will programmers lose their jobs (to Al)? | Demis Hassabis & Lex Fridman July 29, 2025
It’s symbiotic relationship, or it’s not July 17, 2025
Performance July 16, 2025
Shh July 11, 2025
Virtue & Contribution June 14, 2025
Liquid Glass June 11, 2025
Ruby June 9, 2025
Thanks Dave May 28, 2025
Agile—or can you just not figure out what you want? May 24, 2025