Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved the problem! Must call dbus_g_proxy_call with the name "GrabMediaPlayerKeys" (which you also can see in the python code)</p> <p>Must also register a marshaller which is done by first running this command:</p> <pre><code>glib-genmarshal --header --body mediaplayerkeypressed.list &gt; marshal.h </code></pre> <p>and then use it in the dbus_g_object_register_marshaller function.</p> <p>The complete C-code:</p> <pre><code>#include &lt;glib.h&gt; #include &lt;dbus/dbus-glib.h&gt; #include "marshal.h" static void media_key_pressed(DBusGProxy *proxy, const char *value1, const char *value2, gpointer user_data) { g_print("mediakey: %s\n",value2); } int main (int argc, char **argv) { DBusGConnection *conn; DBusGProxy *proxy; GError *error; GMainLoop *loop; g_type_init(); error = NULL; conn = dbus_g_bus_get (DBUS_BUS_SESSION, &amp;error); if (!conn) { g_printerr("Failed to connect to the D-BUS daemon: %s\n", error-&gt;message); g_error_free(error); return 1; } loop = g_main_loop_new (NULL, FALSE); if(!loop) { g_printerr("Could not create mainloop\n"); return 1; } proxy = dbus_g_proxy_new_for_name(conn, "org.gnome.SettingsDaemon", "/org/gnome/SettingsDaemon/MediaKeys", "org.gnome.SettingsDaemon.MediaKeys"); if(!proxy) { g_printerr("Could not create proxy object\n"); } error = NULL; if(!dbus_g_proxy_call(proxy, "GrabMediaPlayerKeys", &amp;error, G_TYPE_STRING, "WebMediaKeys", G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_INVALID)) { g_printerr("Could not grab media player keys: %s\n", error-&gt;message); } dbus_g_object_register_marshaller ( g_cclosure_user_marshal_VOID__STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal(proxy, "MediaPlayerKeyPressed", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_connect_signal(proxy, "MediaPlayerKeyPressed", G_CALLBACK(media_key_pressed), NULL, NULL); g_print("Starting media key listener\n"); g_main_loop_run (loop); return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload