0

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

Ray Andrews
  • 532
  • 4
  • 14
  • You need a terminal for `stty` and for getchar. Make sure your keystroke trigger opens your script in a new terminal. – u0b34a0f6ae Jan 15 '12 at 22:59
  • kaizer.se, ok then how do I do it in Gnome? I don't understand what you mean: "keystroke trigger opens your script in a new terminal." My program works perfectly from the command line in an xterm (it has no use in tty, it's just for GUI), the only difficulty is making it work via a hotkey. – Ray Andrews Jan 16 '12 at 04:09

1 Answers1

0

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" &

Ben Rose
  • 43
  • 1
  • 10