dbus学习 - dbus信息查看命令和d-feet工具

学习dbus过程中,想查看自己做的程序的dbus信息,查找到的方法记录一下。

一、dbus-send命令

用dbus-send查看当前system bus或者session bus上面挂载了多少service._lizzywu的博客-CSDN博客中提到了几个命令,记录:

1) 查看system bus上面挂载的service.

命令#dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListActivatableNames

method return time=1685008212.580703 sender=org.freedesktop.DBus -> destination=:1.597 serial=3 reply_serial=2
   array [
      string "org.freedesktop.DBus"
      string "org.freedesktop.login1"
      string "org.freedesktop.fwupd"
      string "org.freedesktop.GeoClue2"
      string "com.ubuntu.LanguageSelector"
      string "com.ubuntu.USBCreator"
      string "com.hp.hplip"
      string "org.freedesktop.ColorManager"
      string "org.freedesktop.systemd1"
      string "com.ubuntu.SoftwareProperties"
      string "org.freedesktop.thermald"
      string "org.freedesktop.Avahi"
      string "org.freedesktop.PolicyKit1"
      string "io.netplan.Netplan"
      string "org.freedesktop.ModemManager1"
      string "org.freedesktop.hostname1"
      string "org.debian.apt"
      string "org.bluez"
      string "org.freedesktop.PackageKit"
      string "org.freedesktop.UPower"
      string "org.freedesktop.UDisks2"
      string "org.freedesktop.network1"
      string "com.ubuntu.SystemService"
      string "com.canonical.UbuntuAdvantage"
      string "org.freedesktop.bolt"
      string "fi.epitest.hostap.WPASupplicant"
      string "org.freedesktop.resolve1"
      string "org.freedesktop.timedate1"
      string "com.ubuntu.WhoopsiePreferences"
      string "org.freedesktop.Accounts"
      string "fi.w1.wpa_supplicant1"
      string "org.freedesktop.RealtimeKit1"
      string "org.opensuse.CupsPkHelper.Mechanism"
      string "org.freedesktop.nm_dispatcher"
      string "org.freedesktop.locale1"
   ]

2)查看session bus上面挂载的service .

命令# dbus-send --session --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListActivatableNames


method return time=1685008285.094553 sender=org.freedesktop.DBus -> destination=:1.98 serial=3 reply_serial=2
   array [
      string "org.freedesktop.DBus"
      string "org.freedesktop.portal.Desktop"
      string "org.freedesktop.systemd1"
      string "org.fedoraproject.Config.Printing"
      string "org.gtk.vfs.Daemon"
      string "org.freedesktop.ColorHelper"
      string "org.gnome.ControlCenter.SearchProvider"
      string "io.snapcraft.SessionAgent"
      string "org.gnome.DejaDup"
      string "org.freedesktop.impl.portal.desktop.gtk"
      string "org.gnome.evolution.dataserver.Sources5"
      string "org.gnome.Terminal"
      string "org.gtk.vfs.UDisks2VolumeMonitor"
      string "org.a11y.Bus"
      string "org.gnome.Calendar"
      string "org.gnome.Identity"
      string "org.gnome.keyring"
      string "org.gnome.Shell.CalendarServer"
      string "org.gnome.font-viewer"
      string "org.freedesktop.PackageKit"
      string "ca.desrt.dconf"
      string "org.gnome.evolution.dataserver.UserPrompter0"
      string "org.gtk.vfs.GPhoto2VolumeMonitor"
      string "org.freedesktop.portal.Documents"
      string "org.gnome.FileRoller"
      string "org.bluez.obex"
      string "org.gnome.Todo"
      string "io.snapcraft.Launcher"
      string "org.gnome.evince.Daemon"
      string "io.snapcraft.Settings"
      string "org.gnome.evolution.dataserver.Calendar7"
      string "io.snapcraft.Prompt"
      string "org.gtk.vfs.AfcVolumeMonitor"
      string "org.freedesktop.FileManager1"
      string "org.gnome.seahorse.Application"
      string "org.gnome.Totem"
      string "org.gnome.Nautilus"
      string "org.gnome.baobab"
      string "org.freedesktop.Telepathy.Client.Vino"
      string "org.gtk.GLib.PACRunner"
      string "org.gtk.vfs.GoaVolumeMonitor"
      string "org.gnome.ArchiveManager1"
      string "org.gnome.Cheese"
      string "org.gnome.Shell.PortalHelper"
      string "org.gnome.OnlineAccounts"
      string "org.freedesktop.portal.IBus"
      string "org.gnome.zeitgeist.Engine"
      string "org.gnome.evolution.dataserver.AddressBook9"
      string "org.gtk.vfs.Metadata"
      string "org.gnome.Shell.HotplugSniffer"
      string "org.freedesktop.impl.portal.PermissionStore"
      string "org.gnome.Rhythmbox3"
      string "org.gnome.keyring.SystemPrompter"
      string "org.gnome.DiskUtility"
      string "org.gnome.gedit"
      string "org.gnome.ControlCenter"
      string "org.freedesktop.secrets"
      string "org.gtk.vfs.MTPVolumeMonitor"
      string "org.gnome.keyring.PrivatePrompter"
      string "org.gnome.zeitgeist.SimpleIndexer"
      string "org.gnome.Screenshot"
      string "org.freedesktop.IBus"
      string "org.gnome.Software"
   ]

调用org.freedesktop.Dbus提供的标准接口:

# dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.Introspectable.Introspect


method return time=1685008446.660151 sender=org.freedesktop.DBus -> destination=:1.599 serial=3 reply_serial=2
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="org.freedesktop.DBus">
    <method name="Hello">
      <arg direction="out" type="s"/>
    </method>
    <method name="RequestName">
      <arg direction="in" type="s"/>
      <arg direction="in" type="u"/>
      <arg direction="out" type="u"/>
    </method>
    <method name="ReleaseName">
      <arg direction="in" type="s"/>
      <arg direction="out" type="u"/>
    </method>
    <method name="StartServiceByName">
      <arg direction="in" type="s"/>
      <arg direction="in" type="u"/>
      <arg direction="out" type="u"/>
    </method>
    <method name="UpdateActivationEnvironment">
      <arg direction="in" type="a{ss}"/>
    </method>
    <method name="NameHasOwner">
      <arg direction="in" type="s"/>
      <arg direction="out" type="b"/>
    </method>
    <method name="ListNames">
      <arg direction="out" type="as"/>
    </method>
    <method name="ListActivatableNames">
      <arg direction="out" type="as"/>
    </method>
    <method name="AddMatch">
      <arg direction="in" type="s"/>
    </method>
    <method name="RemoveMatch">
      <arg direction="in" type="s"/>
    </method>
    <method name="GetNameOwner">
      <arg direction="in" type="s"/>
      <arg direction="out" type="s"/>
    </method>
    <method name="ListQueuedOwners">
      <arg direction="in" type="s"/>
      <arg direction="out" type="as"/>
    </method>
    <method name="GetConnectionUnixUser">
      <arg direction="in" type="s"/>
      <arg direction="out" type="u"/>
    </method>
    <method name="GetConnectionUnixProcessID">
      <arg direction="in" type="s"/>
      <arg direction="out" type="u"/>
    </method>
    <method name="GetAdtAuditSessionData">
      <arg direction="in" type="s"/>
      <arg direction="out" type="ay"/>
    </method>
    <method name="GetConnectionSELinuxSecurityContext">
      <arg direction="in" type="s"/>
      <arg direction="out" type="ay"/>
    </method>
    <method name="GetConnectionAppArmorSecurityContext">
      <arg direction="in" type="s"/>
      <arg direction="out" type="s"/>
    </method>
    <method name="ReloadConfig">
    </method>
    <method name="GetId">
      <arg direction="out" type="s"/>
    </method>
    <method name="GetConnectionCredentials">
      <arg direction="in" type="s"/>
      <arg direction="out" type="a{sv}"/>
    </method>
    <property name="Features" type="as" access="read">
      <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
    </property>
    <property name="Interfaces" type="as" access="read">
      <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const"/>
    </property>
    <signal name="NameOwnerChanged">
      <arg type="s"/>
      <arg type="s"/>
      <arg type="s"/>
    </signal>
    <signal name="NameLost">
      <arg type="s"/>
    </signal>
    <signal name="NameAcquired">
      <arg type="s"/>
    </signal>
  </interface>
  <interface name="org.freedesktop.DBus.Properties">
    <method name="Get">
      <arg direction="in" type="s"/>
      <arg direction="in" type="s"/>
      <arg direction="out" type="v"/>
    </method>
    <method name="GetAll">
      <arg direction="in" type="s"/>
      <arg direction="out" type="a{sv}"/>
    </method>
    <method name="Set">
      <arg direction="in" type="s"/>
      <arg direction="in" type="s"/>
      <arg direction="in" type="v"/>
    </method>
    <signal name="PropertiesChanged">
      <arg type="s" name="interface_name"/>
      <arg type="a{sv}" name="changed_properties"/>
      <arg type="as" name="invalidated_properties"/>
    </signal>
  </interface>
  <interface name="org.freedesktop.DBus.Introspectable">
    <method name="Introspect">
      <arg direction="out" type="s"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Monitoring">
    <method name="BecomeMonitor">
      <arg direction="in" type="as"/>
      <arg direction="in" type="u"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Debug.Stats">
    <method name="GetStats">
      <arg direction="out" type="a{sv}"/>
    </method>
    <method name="GetConnectionStats">
      <arg direction="in" type="s"/>
      <arg direction="out" type="a{sv}"/>
    </method>
    <method name="GetAllMatchRules">
      <arg direction="out" type="a{sas}"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Peer">
    <method name="GetMachineId">
      <arg direction="out" type="s"/>
    </method>
    <method name="Ping">
    </method>
  </interface>
</node>
"
#dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames


method return time=1685008477.990272 sender=org.freedesktop.DBus -> destination=:1.600 serial=3 reply_serial=2
   array [
      string "org.freedesktop.DBus"
      string ":1.106"
      string ":1.7"
      string ":1.107"
      string ":1.8"
      string ":1.108"
      string ":1.109"
      string "org.freedesktop.systemd1"
      string "org.freedesktop.ModemManager1"
      string "org.freedesktop.NetworkManager"
      string "org.freedesktop.resolve1"
      string "org.freedesktop.RealtimeKit1"
      string "org.freedesktop.Accounts"
      string ":1.80"
      string ":1.81"
      string ":1.83"
      string ":1.84"
      string "com.ubuntu.SoftwareProperties"
      string "org.freedesktop.PolicyKit1"
      string ":1.20"
      string "org.bluez"
      string ":1.21"
      string ":1.66"
      string ":1.22"
      string ":1.450"
      string ":1.89"
      string "org.freedesktop.PackageKit"
      string ":1.67"
      string ":1.23"
      string ":1.594"
      string ":1.572"
      string ":1.110"
      string ":1.68"
      string ":1.24"
      string ":1.573"
      string ":1.69"
      string ":1.25"
      string ":1.574"
      string ":1.112"
      string ":1.575"
      string "com.redhat.NewPrinterNotification"
      string ":1.27"
      string ":1.576"
      string "org.freedesktop.bolt"
      string "fi.epitest.hostap.WPASupplicant"
      string ":1.577"
      string ":1.29"
      string ":1.579"
      string "com.redhat.PrinterDriversInstaller"
      string "com.ubuntu.USBCreator"
      string ":1.538"
      string "org.gnome.DisplayManager"
      string ":1.517"
      string ":1.518"
      string "org.freedesktop.Avahi"
      string ":1.519"
      string "org.freedesktop.UDisks2"
      string "com.ubuntu.SystemService"
      string ":1.90"
      string "fi.w1.wpa_supplicant1"
      string "org.freedesktop.fwupd"
      string ":1.70"
      string "org.freedesktop.login1"
      string "com.ubuntu.LanguageSelector"
      string ":1.93"
      string ":1.71"
      string "com.hp.hplip"
      string ":1.94"
      string "org.freedesktop.ColorManager"
      string ":1.72"
      string ":1.95"
      string "io.netplan.Netplan"
      string ":1.580"
      string ":1.32"
      string ":1.99"
      string ":1.77"
      string ":1.11"
      string ":1.33"
      string ":1.120"
      string ":1.12"
      string ":1.34"
      string "org.freedesktop.UPower"
      string ":1.121"
      string ":1.79"
      string ":1.0"
      string ":1.100"
      string ":1.36"
      string ":1.1"
      string ":1.585"
      string ":1.101"
      string ":1.2"
      string ":1.102"
      string ":1.3"
      string "com.canonical.UbuntuAdvantage"
      string ":1.103"
      string ":1.4"
      string ":1.5"
      string ":1.18"
      string ":1.600"
      string ":1.105"
      string ":1.6"
      string ":1.19"
   ]

更多信息可以查看:https://dbus.freedesktop.org/doc/dbus-specification.html

二、d-feet工具查看

按着d-feet工具

sudo apt install d-feet

执行d-feet: 

 #d-feet

如果在ssh终端执行,会打印如下内容,这可能是因为无法显示界面导致的。可以在linux系统界面命令行输入,即可显示所有的dbus信息。

Unable to init server: Could not connect: Connection refused
Unable to init server: 无法连接: Connection refused
Unable to init server: 无法连接: Connection refused

(d-feet:29916): Gtk-WARNING **: 17:58:29.735: cannot open display: 

dbus分为System Bus和Session Bus,在输入框输入对应的Bus name,即可查看。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值