SD_BUS_SET_PROPERTY(3)

πŸ’… SD_BUS_SET_PROPERTY(3) β€” the sd_bus_set_property girlies

okay so bestie, welcome to the sd_bus_set_property manual page, aka your lil' group chat with D-Bus properties. pull up a chair, grab a boba, we're getting into it πŸ’–


✨ NAME ✨

sd_bus_set_property, sd_bus_set_propertyv, sd_bus_get_property, sd_bus_get_property_trivial, sd_bus_get_property_string, sd_bus_get_property_strv β€” set or query D-Bus service properties. literally the whole friend group 🫢


🌸 SYNOPSIS 🌸

#include <systemd/sd-bus.h>

int sd_bus_set_property(sd_bus *bus, const char *destination,
                        const char *path, const char *interface,
                        const char *member, sd_bus_error *ret_error,
                        const char *type, ...);

int sd_bus_set_propertyv(sd_bus *bus, const char *destination,
                         const char *path, const char *interface,
                         const char *member, sd_bus_error *ret_error,
                         const char *type, va_list ap);

int sd_bus_get_property(sd_bus *bus, const char *destination,
                        const char *path, const char *interface,
                        const char *member, sd_bus_error *ret_error,
                        sd_bus_message **reply, const char *type);

int sd_bus_get_property_trivial(sd_bus *bus, const char *destination,
                                const char *path, const char *interface,
                                const char *member,
                                sd_bus_error *ret_error, char type,
                                void *ret_ptr);

int sd_bus_get_property_string(sd_bus *bus, const char *destination,
                               const char *path, const char *interface,
                               const char *member,
                               sd_bus_error *ret_error, char **ret);

int sd_bus_get_property_strv(sd_bus *bus, const char *destination,
                             const char *path, const char *interface,
                             const char *member,
                             sd_bus_error *ret_error, char ***ret);

πŸ¦‹ DESCRIPTION πŸ¦‹

so these functions set or query D-Bus properties. and like β€” what is a D-Bus property? it's a service field exposed via the org.freedesktop.DBus.Properties interface. under the hood, these functions call methods of the org.freedesktop.DBus.Properties interface, and as a result their semantics are similar to those of sd_bus_call_method(3). iykyk ✨

  • sd_bus_set_property() β€” sets a D-Bus property. if setting the property fails, or an internal error occurs, an error is returned and an extended description of the error is optionally stored in ret_error if it is not NULL. type and the arguments that follow it describe the new value of the property and must follow the format described in sd_bus_message_append(3). no cap, follow the format.
  • sd_bus_set_propertyv() β€” equivalent to sd_bus_set_property(), except that it is called with a "va_list" instead of a variable number of arguments. same energy, different vibes.
  • sd_bus_get_property() β€” queries a D-Bus property. if retrieving the property fails, or an internal error occurs, an error is returned and an extended description of the error is optionally stored in ret_error if it is not NULL. on success, the property is stored in reply. type describes the property type and must follow the format described in sd_bus_message_append(3). slay.
  • sd_bus_get_property_trivial(), sd_bus_get_property_string() and sd_bus_get_property_strv() β€” these are shorthands for sd_bus_get_property() used to query basic, string and string vector properties respectively. and bestie, listen β€” the caller is responsible for freeing the string and string vector results stored in ret by sd_bus_get_property_string() and sd_bus_get_property_strv(). that's your mess to clean up, not ours πŸ™ˆ

πŸ”₯ RETURN VALUE πŸ”₯

on success, these functions return a non-negative integer. on failure, they return a negative errno-style error code. that's it, that's the vibe check. πŸ’€

😭 Errors

see the sd_bus_call_method(3) man page for a list of possible errors. we're not gonna list 'em all here, go read the other one, it eats.


πŸ‘‘ NOTES πŸ‘‘

  • functions described here are available as a shared library, which can be compiled against and linked to with the libsystemd pkg-config(1) file. cute, convenient, iconic.
  • all functions listed here are thread-agnostic and only a single thread may operate on a given object at any given time. different threads may access the same object at different times. multiple independent objects may be used from different threads in parallel. so like, share the object politely, bestie 🫢
⚠️ the code described here uses getenv(3), which is declared to be not multi-thread-safe. this means that the code calling the functions described here must not call setenv(3) from a parallel thread. it is recommended to only do calls to setenv() from an early phase of the program when no other threads have been started. do NOT be messy about this one, fr fr.

🌈 HISTORY 🌈

sd_bus_set_property(), sd_bus_set_propertyv(), sd_bus_get_property(), sd_bus_get_property_trivial(), sd_bus_get_property_string(), and sd_bus_get_property_strv() were added in version 246. glow-up era ✨


πŸŽ€ SEE ALSO πŸŽ€

systemd(1), sd-bus(3), sd_bus_call_method(3)


and that's the page, bestie!! mwah πŸ’‹ this lil' number is brought to you by systemd 261.3 β€” the source/version flex β€” and it's dated with love under the SD_BUS_SET_PROPERTY(3) banner. go forth and set those properties. periodt. πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from