I would like to create a simple tool that allows me to track down events that happen on the desktop, e.g. an application's window is opened or closed, a file was opened/closed etc..I am experimenting with some stuff, such as knotify and kwindowsystem. However don't know whether this is the right way or whether these are the right libraries to work with. Any help in this regards is welcome.

thanks in advance