This is probably a weird question, so prepare yourselves.
I'm writing a little program to display an estimate of my battery life on my xmobar status bar. I was using a program I've found which watches for CAPSLOCK and does something similar. However, in my program the infinite while loop uses way too much of my CPU. I've picked apart the example CAPSLOCK program and I've found that the reason it doesn't take 99% of my CPU is this
I'm guessing this function waits for an X event before moving on to the next line of code. So, the effect of this is that the while(1) loop in which this function call lives slows down and doesn't consume too much CPU.
So, does anyone know a way to get a similar effect without having to bother the X server?
look at battery file and calculate time left
print info to stdout
wait a few seconds