in Gnome/metacity can we bind a key to a command that requires user input from the keyboard?

148 views Asked by At

All,

I have a little 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");

It grabs the keystroke and doesn't need to wait for ENTER. It works fine from the command line, however, when I try to bind the command to a hotkey in Gnome/metacity, it waits for the keystroke alright, but the keystroke seems to be processed not as as input to the command, 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"

I've tried it without the "system" lines, but nothing changed. Is there perhaps some special version of "getchar" that works with the GUI? Incidentally, 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.

Thanks

1

There are 1 answers

0
Ben Rose On

I believe GTK may interest you, although I've never personally used it.

http://www.gtk.org/

.

You should also be able to run gnome-terminal. Using /opt/appFoo/appFoo as the command to run your app normally, you would run

gnome-terminal -e "/opt/appFoo/appFoo" &