Problem to get keyboard events on a window via standard x commands
"sinecosa" <[email protected]>
| Newsgroups | gmane.comp.xfree86.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello,
Sorry to post on the same topic, but I realised the problem is
more for developppers (I posted this topic before in XfREE86
mailing list).
I try to write a shell script, that allows the following
feature: the script, when started, allows you to press anykey
from the keyboard, and do something you want, Otherwise no key
is pressed and after 10 secondes, leave. There si no problem
with keys relied to "printable" characters, but the script has
no effect using a "Ctrl" or "Shift" key for instance.
I have tried to set all the keycodes of the keyboard to
a printable letter (for say to letter "a") using
for all known keycodes with number i, do
xmodmap -e "keycode i = a".
But when I go back and set my keycodes to default keycodes,
then I have problems with some keys using AltGr
I am french and for say the following characters
~#{[|`\^@
on my keyboard are accessed via the AltGr key.
Setting keycodes for these keys "erase" the meaning of these
keys used with the key AltGr
More over such a script is a problem since access to the
keyboard via other applications isn't possible during this time.
As many keyboards exist, and I would like my script to
be used by everyone, I think I have to developp my own
command. As I don't know all of X features, my question
is: does there exist a way to write a script using
default commands in X that would do what I expect ?
I tried also xev, using it like this in a shell script:
xev -id current_window_id > event_results &
while true; do
{
if [ couterclockwise= 0 ]; then
echo "do something"
break
fi
echo sleep 1
if [ -n "$(grep -i -e keycode -e keypress -e keyrelease)" ]; then
echo "a key has been hitten: do something else"
fi
}
But the file "event_results" doesn't record wanted results.
and can get info via xwininfo, but I cannot use them in my script.
So do I have to write my own command using Xlib ?
Thanks, Xavier.