简体   繁体   English

使用 Linux 接收系统密钥的信号?

[英]Receive Signal for System Key using Linux?

I want to register my Application (its a Gtk Application) to receive a signal when the user presses for example the "Next Song" Button, while it is not focused, so the User can change the playback while the Application remains in the background.我想注册我的应用程序(它是一个 Gtk 应用程序)以在用户按下例如“下一首歌曲”按钮时接收信号,而它没有聚焦,因此用户可以在应用程序保持在后台时更改播放。 I have no idea how to do this - will I need to include a specific Library for doing this on Ubuntu 18.04?我不知道该怎么做——我需要在 Ubuntu 18.04 上包含一个特定的库吗? Just to clarify: I am talking about System-Wide Hotkeys that applications can somehow intercept.澄清一下:我说的是应用程序可以以某种方式拦截的系统范围的热键。

There isn't really a generic mechanism for this in Wayland (the security issues should be pretty obvious);在 Wayland 中并没有真正的通用机制(安全问题应该很明显); for X, see the XGrabKey function.对于 X,请参见XGrabKey函数。

For multimedia keys, there is a D-Bus interface you can use at org.gnome.SettingsDaemon.MediaKeys.对于多媒体键,您可以在 org.gnome.SettingsDaemon.MediaKeys 使用 D-Bus 接口。 For an example of how to use it, take a look at plugins/nmkeys/rb-mmkeys-plugin.c in Rhythmbox .有关如何使用它的示例,请查看Rhythmbox 中的 plugins/nmkeys/rb-mmkeys-plugin.c

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

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