jesseleite / GridLayout.spoon

🖥️ Grid based window layout presets for your Macintosh™
12 stars 0 forks source link

Unable to fetch NSRunningApplication for pid `PID` #6

Open TechDufus opened 1 month ago

TechDufus commented 1 month ago

Every now and then I am unable to run my bind for layout.bindToCell with the following error:

2024-10-08 16:28:24: 16:28:24 ERROR:   LuaSkin: Unable to fetch NSRunningApplication for pid: 50647
2024-10-08 16:28:24: 16:28:24 ERROR:   LuaSkin: hs.hotkey callback: ...USER/.hammerspoon/Spoons/GridLayout.spoon/helpers.lua:107: attempt to index a nil value
stack traceback:
    ...USER/.hammerspoon/Spoons/GridLayout.spoon/helpers.lua:107: in field 'listAppsInCells'
    ...s/USER/.hammerspoon/Spoons/GridLayout.spoon/init.lua:90: in function 'GridLayout.bindToCell'
    /Users/USER/.hammerspoon/init.lua:91: in function </Users/USER/.hammerspoon/init.lua:91>

This is odd when there is no currently running pid 50647 in this example. I've checked ps, Activity Monitor, and simply tried killing the pid but it's just not a running pid. Wondering why GridLayout is hanging on to it?

The result is that I cannot successfully run this bindToCell function, moving apps around and whatnot...

TechDufus commented 1 month ago

Quitting and restarting hammerspoon works around this issue.

jesseleite commented 1 month ago

Let me know if it keeps happening, but I have no idea what's causing it.

If so, curious if you can narrow down which app is causing it.

TechDufus commented 1 month ago

Doing a Reload Config also works to refresh this.

jesseleite commented 1 month ago

Ah figured out what causes this. If you bind a window to a cell using bindToCell, then close that app, then re-open that app, it'll have a different pid.

We should gracefully handle this. Maybe look for app with same name, and if that can't be found, just remove it from the cell bindings table when pid can't be found.