I often hibernate my machine. I want to trigger a program to run immediately
after restore and immediately before hibernate.

Lets focus on the restore. I know how you put programs in .kde/Autostart to
trigger them on login (start of KDE). But I am looking for a program to
start when I unlock the screensaver after resume (Ok, this won't work for
KDE 4 since you do not get a screensaver lock on resume with KDE 4, but I
am not using that).

Any way to do this ?