I build these very nice arrangements with desktops/ spaces for tasks + windows sized and side-by-side...
And then, I wake it from stand-by the next day, and everything is pilled up like crap on the internal desktop... Is there any elegant solution to this?
If your second monitor is permanently connected this won't happen. I have a Mac Desktop Computer with attached secondary display and on each wake from sleep the windows stay in their previous places on both monitors.
Also, I just tried putting my Mac to sleep. Disconnecting the second display. Reconnecting the second display. And waking from sleep. And all windows were arranged as before.
So, I don't think what you are describing is normal behaviour.
I have this issue too. (Perhaps the situation wasn't described accurately.) When I detach the external monitor and use my MBP away from my desk, all windows re-open on the internal display. They don't go back to where they were previously when you re-attach the external display.
The good news: I tried your macro, Zabobon, and it does what I want. I set up a workspace to position apps for when I have both displays. Then if I re-boot, or re-attach the external display after running without it, I can use the key-stroke to restore the app positions.
Because I have to type a key-stroke, it isn't "automatic", but I don't have to do any adaptation of your macro, either. And I have the flexibility of being able to restore several different app configurations.