Results 1 to 5 of 5
Hi.
Im trying to execute some actions when there's no keyboard action in "x" seconds or minutes (after "x" seconds or minutes of keyboard inactivity), but is hard to find ...
- 04-03-2010 #1Just Joined!
- Join Date
- Apr 2010
- Posts
- 2
[C++] how to execute some action after "x" seconds of keyboard inactivity?
Hi.
Im trying to execute some actions when there's no keyboard action in "x" seconds or minutes (after "x" seconds or minutes of keyboard inactivity), but is hard to find something about this...
and i dont know if this will make a lot of cpu usage
- 04-03-2010 #2
This is what the powermanager/screensaver from Gnome/KDE/etc. basically does. So I would look how they do it.
Debian GNU/Linux -- You know you want it.
- 04-04-2010 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
GNU-Fan's suggestion is reasonable is you are talking about a system where the USER is running an X-Windows desktop (KDE, Gnome, XFCE, etc). It really depends a lot on the environment. As for CPU utilization, it should not be an issue, unless you use a polling construct to detect the keypress. Normally this would be an event-driven handler. It sounds like you need to do some studying of how to deal with hardware asyncronous events in user-space programs.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 04-04-2010 #4Just Joined!
- Join Date
- Apr 2010
- Posts
- 2
im using fluxbox, no kde/gnome. and no user, just root (its an embeeded linux)
- 04-04-2010 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
Well, in that case I would download the fluxbox source and see what they do to trigger the screen saver. Since it is an X-Windows application, they undoubtedly trap keypress events anywhere on the screen to reset the timer. It's not that hard to do with low-level Xlib functions, but then it isn't trivial either. Basically, you need a timer that will start your program when it expires, and a kepress XEvent handler that will reset the timer when it detects a keypress anywhere on the screen.
The source for fluxbox is available here: fluxbox.org - downloadSometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote