![]() |
Question: Determining window focus from shell script
Greetings,
I'm writing a simple shell script that needs the user to go to the camera, take a picture, and manually return to xterminal (which is already open previously). My question: Is there any way I can detect which application currently has the focus from a shell script? Or the reverse: Is there any way that I can check whether an application has been "backgrounded"? Alternatively, rather than using a "pure" shell script, is there any simple python implementation of the above? In this case I can call the python interpreter to check the application state from the shell script and process accordingly. Thanks :) |
Answer (Sort of!): Determining window focus from shell script
1 Attachment(s)
Replying to myself here :p
I found that xprop can be used to enumerate all windows in an X11 session and retrieve the top-most (focused) window. For the technically-inclined, I have uploaded some scripts for your reference/use. This method requires installation of x11-utils from the Maemo Fremantle/Tools repository. The instructions can be found here: http://talk.maemo.org/showthread.php...731#post448731. After installing x11-utils, xprop will be available on the console. The uploaded files consist of:
Usage: x11-wait-for-topmost.sh [WM_CLASS] [EVENT] [TIMEOUT]
Example: Code:
./x11-wait-for-topmost.sh camera-ui Both of these commands do the same thing, the script will wait until the camera application runs and receives the focus (try opening the camera slide).Notes:
|
All times are GMT. The time now is 20:24. |
vBulletin® Version 3.8.8