Summary

Applications can access the proximity sensor by using the DBusProxy class from the Gio module to talk to a D-Bus service. The API provided by the service can also be used to access other sensors.

It can be useful to wrap the communication code in a separate class and use its API from GUI code. This example includes a simple class that performs this task.

When distributed as a flatpak, the manifest needs to include the --system-talk-name=net.hadess.SensorProxy permission that allows the application to access the net.hadess.SensorProxy service on the system D-Bus.