目录
d-feet客户端
d-feet是比较好用的dbus工具,他使用python语言编写的,并且他有可视化界面,在d-feet工具内可以方便的看到系统dbus接口以及session的dbus接口,在查询dbus接口方面是非常不错的.缺点在于如果希望编写自动化脚本测试dbus接口,d-feet客户端就不行了(也许有方法我不知道)
客户端安装
sudo apt install d-feet
详细内容可以看:-> D-Feet的复杂类型使用攻略(DBUS)
qdbus客户端
qdbus客户端是qt的开发客户端工具。使用命令行进行控制,可以很方便的编写自动化用例.
该工具使用table健也可以很方便的查找,dbus接口。
qdbus客户端安装如下:
sudo apt install qtchooser
使用方法如下:
Usage: qdbus [--system | --address ADDRESS] [--literal] [servicename] [path] [method] [args]
servicename the service to connect to (e.g., org.freedesktop.DBus)
path the path to the object (e.g., /)
method the method to call, with or without the interface
args arguments to pass to the call
With 0 arguments, qdbus will list the services available on the bus
With just the servicename, qdbus will list the object paths available on the service
With service name and object path, qdbus will list the methods, signals and properties available on the object
Options:
--system connect to the system bus
--address ADDRESS connect to the given bus
--literal print replies literally
使用案例
qdbus --literal com.ubx.server /com/ubx/server org.freedesktop.DBus.Introspectable.Introspect
执行结果
gdbus客户端
sudo apt install libglib2.0-bin
详细可以点击:-> gdbus命令客户使用攻略
dbus-send客户端
dbus-send是dbus自带的客户端工具
sudo apt install dbus
ddbus-send工具使用方法和qdbus很相识,dbus自带的工具,一般系统都会有,所以不需要安装额外的工具。
用法如下:
dbus-send [--system | --session | --bus=ADDRESS | --peer=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] <destination object path> <message name> [contents ...]
dbus-send⽀持的参数类型包括:string, int32, uint32, double, byte, boolean
dbus-send --session --print-reply --dest=org.freedesktop.Notifications /org/freedesktop/Notifications com.deepin.dde.Notification.Show
运行结果
method return time=1655429935.909792 sender=:1.2305 -> destination=:1.2396 serial=731 reply_serial=2
如果函数需要传递参数
dbus-send --system --print-reply --dest=org.bluez /org/bluez/audio org.bluez.audio.Manager.CreateDevice string:'11:11:11:11:11:11'