在 Gnome/metacity 中,我们可以将一个键绑定到需要用户从键盘输入的命令吗?
所有,
我有一个用 C 编写的小实用程序,需要用户按一个键来进行菜单选择。可以预见,代码很简单:
system("stty raw");
save_ID = getchar();
system("stty cooked");
它捕获击键并且不需要等待 ENTER。它在命令行中运行良好,但是,当我尝试将命令绑定到 Gnome/metacity 中的热键时,它会等待击键,但击键似乎不会被处理为命令的输入,而是好像这是一个单独的命令。例如。如果我的击键是“1”并且我在终端中,我会看到:
“zsh:找不到命令:1”
我已经在没有“系统”行的情况下尝试过它,但没有任何改变。是否有一些特殊版本的“getchar”可以与 GUI 一起使用?顺便说一句,该程序的非交互式版本在绑定到热键时可以正常工作,因此该程序基本上可以正常工作,只是不能交互式使用。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信 GTK 可能会让您感兴趣,尽管我个人从未使用过它。
http://www.gtk.org/
。
您还应该能够运行 gnome-terminal。使用 /opt/appFoo/appFoo 作为正常运行应用程序的命令,您将运行
gnome-terminal -e "/opt/appFoo/appFoo" &
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" &