dbus-send和dbus-monitor简单使用及可视化工具

dbus参数类型

CharacterCode Data Type
y8-bit unsigned integer
bboolean value
n16-bit signed integer
q16-bit unsigned integer
i32-bit signed integer
u32-bit unsigned integer
x64-bit signed integer
t64-bit unsigned integer
ddouble-precision floating point (IEEE 754)
sUTF-8 string (no embedded nul characters)
oD-Bus Object Path string
gD-Bus Signature string
aArray
(Structure start
)Structure end
vVariant type (described below)
{Dictionary/Map begin
}Dictionary/Map end
hUnix 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好用。
在这里插入图片描述

  • 6
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值