I've been wanting to write a program that can analyze my time spent at the computer (including the amount of time I spend on Perlmonks) by observing what I do. I figured that I could monitor which of the windows on my screen was frontmost, and get its title, or find the commandline of the process that owns the window, or analyze its open files, or something to help my program determine which of several tasks I'm working on.
I looked in CPAN and didn't find any way to interact with the window manager (I'm using X Windows under Linux, with the kdm window manager, but there is a semi-standard WM API under X).
Does anyone know how to:<bl>
Find which window has focus (has to be sensitive to multiple desktops, if it makes any difference)
Find which application (PID) owns that window
</bl>
I realize I could use XS, or my new favorite Inline, but I was hoping I wouldn't have to learn all about X to do this...
Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.