Writing my own typing monitor program for RSI sufferers...

S

samslists

Hi...

I want to write a program that will let me know after thirty minutes of
typing that I need to take a five minute typing break. But when I stop
typing it's smart enough to pause the 30 minute timer automatically.
This is under the X-Window System (Linux).

The tricky part is obviously knowing when the mouse and keyboard are
being used....especially when my application doesn't have the focus.

Obviously I can't do this with just the base python install. Is there
an add on library that I can use to monitor the keyboard and mouse?
Which is it? Maybe one of the graphical libraries, like wx, or qt, or
gtk? Which functions do I need?

Thanks
 
S

samslists

So, so close.... The problem with this implementation is that it
doesn't monitor usb keyboards under linux at all as far as I can
tell....since no keyboard entry will show up in /proc/interrupts with a
usb keyboard. I absolutely need the keyboard monitoring as well.

Otherwise, your project would be the perfect starting point for me!

Anyone else have an idea as to what I can use with Python to know when
the keyboard is being used even when I don't have focus?

Thanks
Sam
 
D

Diez B. Roggisch

So, so close.... The problem with this implementation is that it
doesn't monitor usb keyboards under linux at all as far as I can
tell....since no keyboard entry will show up in /proc/interrupts with a
usb keyboard. I absolutely need the keyboard monitoring as well.

Otherwise, your project would be the perfect starting point for me!

Anyone else have an idea as to what I can use with Python to know when
the keyboard is being used even when I don't have focus?

If you can wait a few month, I'll be doing that in python based on this:

http://www.frogmouth.net/hid-doco/linux-hid.html

I'll be doing it for a art-project that is scheduled some months away. But I think the above information even should
help you get started on your own.

Diez
 
S

skip

> So, so close.... The problem with this implementation is that it
> doesn't monitor usb keyboards under linux at all as far as I can
> tell....since no keyboard entry will show up in /proc/interrupts with
> a usb keyboard. I absolutely need the keyboard monitoring as well.

Sam's> Otherwise, your project would be the perfect starting point for me!

Hmmm... I'm confused. It is a starting point, just not one that monitors
USB keyboards. A "perfect" starting point would be one in which you didn't
need to make any changes. Why throw the baby out with the bath water? Why
not just rewrite check_linux_interrupts to somehow watch the usb keyboard as
well (however that might be done)? It's not going to be any more difficult
to check for USB keyboard interrupts in this project than in some other and
it already has a more-or-less functional user interface and support for
Windows.

Skip
 
S

samslists

Well, this is the one part that I have no idea how to do....as far as I
can tell the information simply is not in /proc. I need a different
method to discover when someone is typing. That's what I came to the
list for, to get a clue as to how to do that.

Certainly someone has an idea how to detect typing on a usb keyboard
under python....some external library must exist?

Thanks

p.s. Diez...I'll read that over, and will look forward to seeing what
you come up with. Please email me to let me know......I suspect that
your approach will require kernel modifications.... I don't want to go
down that path. I'd be okay with it once, cut the last thing I want to
do is repatch my ubuntu kernel every time there was a security fix.
 
C

Carl Friedrich Bolz

I want to write a program that will let me know after thirty minutes of
typing that I need to take a five minute typing break. But when I stop
typing it's smart enough to pause the 30 minute timer automatically.
This is under the X-Window System (Linux).

The tricky part is obviously knowing when the mouse and keyboard are
being used....especially when my application doesn't have the focus.

Obviously I can't do this with just the base python install. Is there
an add on library that I can use to monitor the keyboard and mouse?
Which is it? Maybe one of the graphical libraries, like wx, or qt, or
gtk? Which functions do I need?

You can do a bit of X hackery. Look for example at

http://www.softlab.ece.ntua.gr/~sivann/src/misc/xkey.c

which is a C program that prints keypresses (in any application). Should
be fairly easy to turn into a Python extension module to monitor X activity.

Cheers,

Carl Friedrich Bolz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top