On 10/23/2012 07:39 PM, Zsolt Udvari wrote:
Is it possible to get the current user's inactivity in seconds since the
last keyboard event of the X server?
Maybe:
http://awesome.naquadah.org/doc/api/modules/keygrabber.html
or
http://awesome.naquadah.org/wiki/Signals#key

I don't know which would be better but imho it's a good beginning
(stores the time of last keypress, run a timer in every seconds which
checks the time of last keypress...).

I cannot use the keygrabber in this situation.

The key module looks promising, but I would need to assign a signal to each key on the keyboard. Not very practical.

The best way on X11 would be to use the XScreenSaverQueryInfo call.
I could bake an executable to return this value, but forking a new process at each manage event seems prohibitive.

I'm wondering if there's interest in integrating such a call in awesome.

My current code for focus steal prevention is pretty simple:

1) reset spawn timestamp on each spawn::initiated event and/or modifier keypress (mod1-4) 2) if the spawn timestamp is < spawn threshold, always give focus to new window (and reset timestamp)
3) if idle > typing threshold, give focus to new window
4) do nothing otherwise

I'm using 5 seconds for the spawn threshold, and I was used to "2" for the typing threshold on another implementation a long time ago (I think I implemented this stuff on sawmill back in the day).

The net effect is that you always get focus on programs started by awesome (if they start within 5 seconds that is). Focus is also given to windows that pop immediately after a mod1-4 combo (ctrl-f, and similar CUA bindings). Otherwise at least 2 seconds are necessary after stopping to type before focus is given to random windows.

It's not perfect, but does the right thing most of the time (it is rarely necessary to switch to a new window), but yet it prevents random dialogs to splash in your face while you type (thunderbird is a repeated offender, just to name one).


--
To unsubscribe, send mail to [email protected].

Reply via email to