aboutsummaryrefslogtreecommitdiff
path: root/systray/helpers.c
diff options
context:
space:
mode:
authorJoshua Yun <joshua@joshuayun.com>2025-03-12 01:28:59 -0500
committerJoshua Yun <joshua@joshuayun.com>2025-03-12 01:28:59 -0500
commit3dc4dcc4ca0dee958a56f43e8a635a6d961e7ccc (patch)
treea8c5c08ada9f149d5cd0839b0dfd83d4630aa4eb /systray/helpers.c
parentdf6d37936bac129d1fd7098cdd37f0cf44f1d4f5 (diff)
downloaddwl-3dc4dcc4ca0dee958a56f43e8a635a6d961e7ccc.tar.gz
Systray patch
Diffstat (limited to 'systray/helpers.c')
-rw-r--r--systray/helpers.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/systray/helpers.c b/systray/helpers.c
new file mode 100644
index 0000000..d1af9f8
--- /dev/null
+++ b/systray/helpers.c
@@ -0,0 +1,43 @@
+#include "helpers.h"
+
+#include <dbus/dbus.h>
+
+#include <errno.h>
+#include <stddef.h>
+
+// IWYU pragma: no_include "dbus/dbus-protocol.h"
+// IWYU pragma: no_include "dbus/dbus-shared.h"
+
+int
+request_property(DBusConnection *conn, const char *busname, const char *busobj,
+ const char *prop, const char *iface, PropHandler handler,
+ void *data)
+{
+ DBusMessage *msg = NULL;
+ DBusPendingCall *pending = NULL;
+ int r;
+
+ if (!(msg = dbus_message_new_method_call(busname, busobj,
+ DBUS_INTERFACE_PROPERTIES,
+ "Get")) ||
+ !dbus_message_append_args(msg, DBUS_TYPE_STRING, &iface,
+ DBUS_TYPE_STRING, &prop,
+ DBUS_TYPE_INVALID) ||
+ !dbus_connection_send_with_reply(conn, msg, &pending, -1) ||
+ !dbus_pending_call_set_notify(pending, handler, data, NULL)) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ dbus_message_unref(msg);
+ return 0;
+
+fail:
+ if (pending) {
+ dbus_pending_call_cancel(pending);
+ dbus_pending_call_unref(pending);
+ }
+ if (msg)
+ dbus_message_unref(msg);
+ return r;
+}