Action before / after sleep

I would like my mac to execute a shortcut before it goes to sleep and then the same shortcut right after it wakes up. Is this possible?

It should be, but timing can be tricky for the sleep events:

Oh perfect, thanks, should this also work if I actively put the Mac to sleep?

Just tried it. It works. Thanks!