DBus分为两种类型:
system bus(系统总线),用于系统(Linux)和用户程序之间进行通信和消息的传递;
session bus(回话总线),用于桌面(GNOME, KDE等)用户程序之间进行通信。
import dbus
session_bus = dbus.SessionBus()
system_bus = dbus.SystemBus()
To obtain a proxy object, call the get_object
method on the Bus
. For example, NetworkManager has the well-known name org.freedesktop.NetworkManager
and exports an object whose object path is /org/freedesktop/NetworkManager
, plus an object per network interface at object paths like /org/freedesktop/NetworkManager/Devices/eth0
. You can get a proxy for the object representing eth0 like this:
要获取代理对象,请在总线上调用get_object方法。例如,NetworkManager有一个众所周知的名称org.freedesktop.NetworkManager并导出一个对象路径为/org/f