dbus参数类型
Character | Code Data Type |
---|---|
y | 8-bit unsigned integer |
b | boolean value |
n | 16-bit signed integer |
q | 16-bit unsigned integer |
i | 32-bit signed integer |
u | 32-bit unsigned integer |
x | 64-bit signed integer |
t | 64-bit unsigned integer |
d | double-precision floating point (IEEE 754) |
s | UTF-8 string (no embedded nul characters) |
o | D-Bus Object Path string |
g | D-Bus Signature string |
a | Array |
( | Structure start |
) | Structure end |
v | Variant type (described below) |
{ | Dictionary/Map begin |
} | Dictionary/Map end |
h | Unix file descriptor |
dbus-send命令
Send a message to a message bus.
dbus-send [ --system | --session | --bus=ADDRESS | --peer=ADDRESS ] [--sender=NAME] [--dest=NAME] [ --print-reply [=literal]] [--reply-timeout=MSEC] [--type=TYPE] OBJECT_PATH INTERFACE.MEMBER [CONTENTS...]
The following options are supported:
--dest=NAME
Specify the name of the connection to receive the message.
--print-reply
Block for a reply to the message sent, and print any reply received in a human-readable form. It also means the message type (--type=) is method_call.
--print-reply=literal
Block for a reply to the message sent, and print the body of the reply. If the reply is an object path or a string, it is printed literally, with no punctuation, escape characters etc.
--reply-timeout=MSEC
Wait for a reply for up to MSEC milliseconds. The default is implementation-defined, typically 25 seconds.
--system
Send to the system message bus.
--session
Send to the session message bus. (This is the default.)
--bus=ADDRESS
Register on a message bus at ADDRESS, typically a dbus-daemon.
--peer=ADDRESS
Send to a non-message-bus D-Bus server at ADDRESS. In this case dbus-send will not call the Hello method.
--sender=NAME
Request ownership of name NAME before sending the message. The name will be released when dbus-send exits.
--type=TYPE
Specify method_call or signal (defaults to "signal").
其中,[CONTENTS…]为调用dbus的method传入的参数,格式如下
<contents> ::= <item> | <container> [ <item> | <container>...]
<item> ::= <type>:<value>
<container> ::= <array> | <dict> | <variant>
<array> ::= array:<type>:<value>[,<value>...]
<dict> ::= dict:<type>:<type>:<key>,<value>[,<key>,<value>...]
<variant> ::= variant:<type>:<value>
<type> ::= string | int16 | uint16 | int32 | uint32 | int64 | uint64 | double | byte | boolean | objpath
dbus-send --dest=org.freedesktop.ExampleName \
/org/freedesktop/sample/object/name \
org.freedesktop.ExampleInterface.ExampleMethod \
int32:47 string:'hello world' double:65.32 \
array:string:"1st item","next item","last item" \
dict:string:int32:"one",1,"two",2,"three",3 \
variant:int32:-8 \
objpath:/org/freedesktop/sample/object/name
dbus-monitor命令
The dbus-monitor command is used to monitor messages going through a D-Bus message bus.
dbus-monitor [ --system | --session | --address ADDRESS ] [ --profile | --monitor | --pcap | --binary ] [ watch expressions ]
OPTIONS
--system Monitor the system message bus.
--session Monitor the session message bus. (This is the default.)
--address ADDRESSMonitor an arbitrary message bus given at ADDRESS.
--profile Use the profiling output format.
--monitor Use the monitoring output format. (This is the default.)
dbus-monitor "type='signal',sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'"
[ watch expressions ]的详细参数可以参考如下设置进行组合
type=signal|method
sender=org.fcitx.Fcitx
destination=org.fcitx.Fcitx
path=/inputmethod
interface=org.fcitx.Fcitx.inputMethod
member=GetCurrentIM
也可以多个[ watch expressions ]组合起来使用。
dbus-monitor "destination=org.fcitx.Fcitx" "sender=org.fcitx.Fcitx"
–monitor选项,可以看到dbus调用method的值
–profile选项,无法看到dbus传递的值
可视化工具
D-Feet,推荐使用,可以看到方法的参数和类型。
qdbusviewer,基于Qt编写的小工具,总体没有D-Feet好用。