Forked from http://www.dtek.chalmers.se/~henoch/text/xprintidle.html