Making idle mouse disappear

Is it possible to make an idle mouse dissappear after about 2 seconds, but if it becomes active again it reapears?

I figure there is but I don’t know the functions I would need to do it.