Track keyboard and mouse usage

2006-07-17 Thread dfaber
Hi all,
 I have been searching for a keyboard and mouse tracker on linux. I've
read solutions (watch at sourceforge) which look at /proc/interrupts to
check keyboard or mouse activity. I also read one post where "watch"
seems to have difficulty tracking usb keyboards and mice. So, I'm out
of ideas here.

My goal are:
1. Check keyboard activity. I'm not interested in logging which keys
are pressed or record them.
2. Monitor mouse activity. I want to know the pointer position,
left-clicks, right-clicks, middle-mouse button usage.

I know that these things can be done in a GUI environment. I am looking
for some approach that helps me do this system-wide.

Any suggestions would be welcome. Again, I am looking for trackers on
Linux based machines.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Track keyboard and mouse usage

2006-07-17 Thread dfaber
So, how would I access /dev/input/ devices?
Can I just 'cat' them or read in those files?


Diez B. Roggisch wrote:
> [EMAIL PROTECTED] schrieb:
> > Diez> You could use the /dev/input/event* devices.
> >
> > On the only Linux system I have available (Mojam's CentOS-based web server),
> > /dev/input/* are readable only by root.  That doesn't seem like it would be
> > very useful to tools like watch unless they were to run suid to root
> > (creating other problems).
>
> You don't need to give it root access. A simple rule for the udev that
> looks like this:
>
> KERNEL=="event[0-9]*",NAME="input/%k", MODE="0444"
>
>
> will make the devices world readable. While I haven't thought about any
> security implications that might have (and am not especially
> knowledgeable in such things to be honest), I'm convinced it is way less
> likely to introduce any exploitable holes than suid root would.
> 
> Diez

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Track keyboard and mouse usage

2006-07-17 Thread dfaber
So, how would I access /dev/input/ devices?
Can I just 'cat' them or read in those files?


Diez B. Roggisch wrote:
> [EMAIL PROTECTED] schrieb:
> > Diez> You could use the /dev/input/event* devices.
> >
> > On the only Linux system I have available (Mojam's CentOS-based web server),
> > /dev/input/* are readable only by root.  That doesn't seem like it would be
> > very useful to tools like watch unless they were to run suid to root
> > (creating other problems).
>
> You don't need to give it root access. A simple rule for the udev that
> looks like this:
>
> KERNEL=="event[0-9]*",NAME="input/%k", MODE="0444"
>
>
> will make the devices world readable. While I haven't thought about any
> security implications that might have (and am not especially
> knowledgeable in such things to be honest), I'm convinced it is way less
> likely to introduce any exploitable holes than suid root would.
> 
> Diez

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Track keyboard and mouse usage

2006-07-17 Thread dfaber
Is there no clean method of accessing the keyboard device or the mouse
on linux?
It seems that looking at /proc/interrupts might prove to be useful for
keyboard monitoring. What about checking if the left mouse button is
clicked or finding the position of the cursor on the screen?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Track keyboard and mouse usage

2006-07-17 Thread dfaber
That IS brain-crushingly complicated. However, thanks for the insight.
I really appreciate it.


Dennis Lee Bieber wrote:
> On 17 Jul 2006 21:00:09 -0700, "dfaber" <[EMAIL PROTECTED]> declaimed
> the following in comp.lang.python:
>
> > Is there no clean method of accessing the keyboard device or the mouse
> > on linux?
> > It seems that looking at /proc/interrupts might prove to be useful for
> > keyboard monitoring. What about checking if the left mouse button is
> > clicked or finding the position of the cursor on the screen?
>
>   For a GUI application, it probably depends upon the interface
> supplied by that GUI system... So far as I know, all Linux variants are
> using an X-Window clone as the bottom protocol.
>
>   Problem: X-Window supports remote displays; you'd need a means of
> specifying which display to track (unless you've opened a GUI
> application and that application is asking for positions -- but it may
> not be able to track outside the application window... Sorry to be so
> vague -- I last coded an X interface back in 1990, using xt/DECWindows
> calls; didn't even have a GUI designer available*)
>
>   I don't think anyone has ported raw X-protocol access to Python.
>
>   All those "monitoring" operations you are asking for are "events" to
> a windowing environment, and applications have to "register" for the
> events they are interested in seeing.
>
>
>
> * If working raw xt/DECWindows wasn't bad enough... Add GKS (is that
> still around?) on top of it -- I had a DECWindows UI whose main window
> was a plain drawing region, and GKS was used to handle the underlying
> data. The application was both graphics intensive, and needed a display
> list (in scaleable coordinates to handle window resize) for refresh
> operations; it used a 32 color "data" field, and four or so single color
> "overlays" -- and any one of the five could be enabled/disabled without
> requiring a recomputation of the drawing. This mess was because the
> DECWindows/GKS application was an emulation (at the API level) of a late
> 70s/early 80s RAMTEK graphics engine... The "main" application was
> really something like 50 specialized programs that all "connected" to
> the "graphics engine", drew some data, and exited; allowing other
> programs in the suite to draw on the /same/ window -- which is why the
> need for GKS; refreshes couldn't ask for the source application to
> repaint the screen. {The very oldest version of the software ran on
> PDP-11s, hence the modular programs, the control program would collect
> user data/parameters, write a "common block file" then invoke the needed
> submodule as an overlay.
> --
>   WulfraedDennis Lee Bieber   KD6MOG
>   [EMAIL PROTECTED]   [EMAIL PROTECTED]
>   HTTP://wlfraed.home.netcom.com/
>   (Bestiaria Support Staff:   [EMAIL PROTECTED])
>   HTTP://www.bestiaria.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Track keyboard and mouse usage

2006-07-23 Thread dfaber
Hi Francois,
 Thank you for providing me the evdev link! That was exactly what I was
looking for. Instead of sudo'ing the script, I changed /dev/input/
directory to be world readable.
After that, I had to change the way a file was accessed in evdev.py to:
Line No: 91 #self.fd = os.open(filename, os.O_RDWR |
os.O_NONBLOCK)
self.fd = os.open(filename, os.O_RDONLY | os.O_NONBLOCK)

Runs great.

Thanks again.

[EMAIL PROTECTED] wrote:
> Hello dfaber,
>
> I had the same problem not long ago. I tried to use the Xlib since its
> obvious the X server  has all the events but I couldn't have the mouse
> events if my app was out of focus. If you have a way to do that I'm
> really interested.
>
> Anyway I found this to be a good introduction to Xlib:
> http://users.actcom.co.il/~choo/lupg/tutorials/xlib-programming/xlib-programming.html#preface
>
> Since I didn't find a way to do it I went down to the source of the
> events which are provided by the evdev drivers:
> http://en.wikipedia.org/wiki/Evdev
>
> Fortunately you can use Python to access it:
> http://svn.navi.cx/misc/trunk/python/evdev/
>
> First you need to know your input devices, search the eventX in
> relation to your device here:
> cat /proc/bus/input/devices
>
> Then you can do:
> sudo python evdev.py /dev/input/eventX  # where X is the event number
> in relation to your device (kb is usually zero)
>
> It works well but there is two problems with this solution:
> - the root access is annoying (but I'll have to try Diez suggestion)
> - The X event number of the mouse can change from a PC to another one
> (you need to check the PC first with that cat command and search for
> your "mouse"
>
> francois
>
>
>
>
>
> dfaber wrote:
> > Hi all,
> >  I have been searching for a keyboard and mouse tracker on linux. I've
> > read solutions (watch at sourceforge) which look at /proc/interrupts to
> > check keyboard or mouse activity. I also read one post where "watch"
> > seems to have difficulty tracking usb keyboards and mice. So, I'm out
> > of ideas here.
> >
> > My goal are:
> > 1. Check keyboard activity. I'm not interested in logging which keys
> > are pressed or record them.
> > 2. Monitor mouse activity. I want to know the pointer position,
> > left-clicks, right-clicks, middle-mouse button usage.
> >
> > I know that these things can be done in a GUI environment. I am looking
> > for some approach that helps me do this system-wide.
> >
> > Any suggestions would be welcome. Again, I am looking for trackers on
> > Linux based machines.

-- 
http://mail.python.org/mailman/listinfo/python-list


starting and stopping a program from inside a python script

2006-07-03 Thread dfaber
Aloha!
 I want to terminate a process/program from within a python script.

For example,
if I have a program say foo.sh that starts running, then I can run it
from within a python script using
os.popen('foo.sh') which starts a program/process say 'bar'

At some point later,  I want to kill 'bar'. Currently, I start off the
process and then when the python script exits, the process 'bar' is
still running and I have to issue ps -ef  | grep 'bar' and then kill
it.

Is there any better way of doing this?

-- 
http://mail.python.org/mailman/listinfo/python-list


python and webcam

2006-02-12 Thread dfaber
Hi,
 I have Logitech webcam and I need to grab images on Fedora Core 4 (not
my favorite distro). Are there any python modules available for doing
this? Any hints or suggestions would be welcome. 

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and webcam

2006-02-12 Thread dfaber
It is a  Win32 Python Extension. I am looking for something that work
on Linux.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and webcam

2006-02-12 Thread dfaber
Thank you for your help. I will look around for v4l modules too.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and webcam

2006-02-12 Thread dfaber
Hi again,
 I've tried a the Sane interface from PIL and I get the following
error, when I run the demo_pil.py from the Sane directory.

SANE version: (16777231, 1, 0, 15)
Available devices= [('v4l:/dev/video0', 'Noname', 'Logitech QuickCam
Pro 3000', 'virtual device')]
Traceback (most recent call last):
  File "/PyWebcam/demo_pil.py", line 17, in ?
s.br_x=320. ; s.br_y=240.
  File "/usr/lib/python2.4/site-packages/sane.py", line 150, in
__setattr__
raise AttributeError, 'Inactive option: '+key
AttributeError: Inactive option: br_x


Next, I looked at v4l support for python with absolutely no
documentation. I tried to build the modules and I get the following
error:

 python setup.py build
running build
running build_ext
building 'v4l' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4
-fasynchronous-unwind-tables -D_GN U_SOURCE -fPIC -fPIC
-I/usr/include/python2.4 -c v4l.c -o build/temp.linux-i686- 2.4/v4l.o
v4l.c: In function 'v4l_getImage':
v4l.c:890: warning: pointer targets in assignment differ in signedness
v4l.c: In function 'initv4l':
v4l.c:1585: error: 'VIDEO_AUDIO_BALANCE' undeclared (first use in
this function)
v4l.c:1585: error: (Each undeclared identifier is reported only once
v4l.c:1585: error: for each function it appears in.)
error: command 'gcc' failed with exit status 1


I also looked at libfg http://antonym.org/libfg and I get the following
errors again:
---
python setup.py build
running build
running build_ext
building 'fg' extension
gcc -pthread -shared build/temp.linux-i686-2.4/fgmodule.o -L. -lfg -o
build/lib.linux-i686-2.4/fg.so
/usr/bin/ld: cannot find -lfg
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

I google-ed extensively have so far found only these three packages.
Any ideas why I get these error messages?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python editor recommendation.

2006-05-09 Thread dfaber
I use Eclipse with the Pydev plugin. It's great way to start
familiarizing yourself with Python. The editor has got great features
and the debugger will be a great help too. Vim is great too but may be
not a good idea if you are new to Python.

Good luck!

-- 
http://mail.python.org/mailman/listinfo/python-list