LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Gnome/metacity keybinding won't permit program to wait for a keystroke, (http://www.linuxquestions.org/questions/linux-desktop-74/gnome-metacity-keybinding-wont-permit-program-to-wait-for-a-keystroke-924057/)

rayandrews 01-16-2012 11:23 AM

Gnome/metacity keybinding won't permit program to wait for a keystroke,
 
All,

I have a little GUI utility written in C that requires the user to press a key to make a menu selection. The code is predictably simple:

system("stty raw");
save_ID = getchar();
system("stty cooked");

'getchar()' grabs the keystroke and the two 'system' lines make it so that it doesn't need to wait for ENTER. It works fine from the command line, however, when I bind the command to a hotkey in Gnome with metacity, it waits for the keystroke alright, but the keystroke then seems to be processed not as as input to the command as it should, but as if it were a separate command. Eg. if my keystroke is "1" and I'm in a terminal I see:

"zsh: command not found: 1"

A non-interactive version of the program works fine when bound to a hotkey, so the program is basically functional, it just can't be used interactively when called via a hotkey. Is there anything I can do about this? If metacity won't cooperate, is there some other macro/hotkey utility that would grab the keystroke properly?

Thanks


All times are GMT -5. The time now is 08:58 PM.