This makes the logic of installing idle handlers and layout handlers a bit cleaner and allows us to send wayland request from the script in the future.
and code cleanup