diff options
| author | Nikita Langer <nikitalanger@icloud.com> | 2026-08-22 18:23:18 +0200 |
|---|---|---|
| committer | Nikita Langer <nikitalanger@icloud.com> | 2026-08-22 18:23:18 +0200 |
| commit | 98f342c73911d1ba4afcdcd36bd5b4fb9cade224 (patch) | |
| tree | 1dd0db18d76f5af51e161f919179e84142c3cc25 /systray/helpers.c | |
| parent | 960d0661f6ed5ab6fd9c371c53a5f5b137864da1 (diff) | |
| download | dwl-master.tar.gz dwl-master.tar.bz2 dwl-master.tar.xz dwl-master.zip | |
Diffstat (limited to 'systray/helpers.c')
| -rw-r--r-- | systray/helpers.c | 43 |
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; +} |
