简体   繁体   English

如何在 GNOME 中拦截键盘快捷键

[英]How to intercept keyboard shortcuts in GNOME

I want to write an application which will intercept some keyboards sequences (like those in Emacs – "Cc Cc") and run some function.我想编写一个应用程序来拦截一些键盘序列(比如 Emacs 中的那些 - “Cc Cc”)并运行一些功能。

How can I do this in GNOME?我怎样才能在 GNOME 中做到这一点?

On which level I should do that (kernel, X11, window manager)?我应该在哪个级别执行此操作(内核、X11、窗口管理器)?

To run a commond on a certain key press you can configure that in metacity or compiz (depending which you're running).要在某个按键上运行 commond,您可以在 metacity 或 compiz 中配置它(取决于您正在运行的)。

For metacity run gconf-editor , go to /apps/metacity/keybinding_commands and under there you will see command_1 etc. In there you set the command to run, and then in /apps/metacity/global_keybindings you set the keybindings to match.对于 metacity run gconf-editor ,转到/apps/metacity/keybinding_commands ,在那里你会看到command_1等。在那里你设置命令运行,然后在/apps/metacity/global_keybindings你设置键绑定匹配。 The key for run_command_1 runs the command for command_1 , and so on. run_command_1的键运行command_1的命令,依此类推。

For compiz you want to run ccsm ("compiz config settings manager") and use the Commands plugin to configure it, in more or less the same way.对于 compiz,您希望运行ccsm (“compiz 配置设置管理器”)并使用命令插件以或多或少相同的方式对其进行配置。

For performing an action in Gedit, as far as I know there is no way to do that, unless there is an existing keyboard shortcut for the command you are issuing.对于在 Gedit 中执行操作,据我所知没有办法做到这一点,除非您发出的命令有现有的键盘快捷键。 In that case you may be able to find an app that translates "Cc Cu" into the right shortcut for Gedit.在这种情况下,您可能会找到一个应用程序,将“Cc Cu”翻译成 Gedit 的正确快捷方式。 But I've never done it.但我从来没有做过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM