Linux command
dbus-send 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Send a method call
dbus-send --session --dest=[org.freedesktop.Notifications] [/org/freedesktop/Notifications] [org.freedesktop.Notifications.GetCapabilities]
Send notification
dbus-send --session --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.Notify string:"app" uint32:0 string:"" string:"[Title]" string:"[Body]" array:string:"" dict:string:string:"" int32:5000
List available services
dbus-send --session --dest=org.freedesktop.DBus --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
Call system bus
dbus-send --system --print-reply --dest=[org.freedesktop.hostname1] [/org/freedesktop/hostname1] [org.freedesktop.DBus.Properties.GetAll] string:"[org.freedesktop.hostname1]"
Get property value
dbus-send --session --print-reply --dest=[destination] [object_path] org.freedesktop.DBus.Properties.Get string:"[interface]" string:"[property]"
说明
dbus-send sends a message to a D-Bus message bus, either the system-wide bus or a session bus. It can invoke methods on D-Bus objects or emit signals, and optionally wait for and print replies. The command is useful for scripting interactions with D-Bus services, debugging D-Bus interfaces, and testing service implementations. Arguments are type-annotated (string:, int32:, boolean:, etc.) to construct properly typed D-Bus messages. Common use cases include sending desktop notifications, querying system properties, and controlling media players or other desktop services that expose D-Bus interfaces.
参数
- --session
- Send to session bus.
- --system
- Send to system bus.
- --dest _NAME_
- Destination service name.
- --print-reply
- Block for a reply and print the result in human-readable form.
- --print-reply=literal
- Print reply with string values unescaped and unquoted.
- --type _TYPE_
- Message type: method_call (default) or signal.
- --reply-timeout=_MSEC_
- Timeout in milliseconds to wait for a reply (default: 25000).
- string:, int32:, uint32:, boolean:, double:, byte:, objpath:
- Typed arguments appended to the message.
- --help
- Display help information.
FAQ
What is the dbus-send command used for?
dbus-send sends a message to a D-Bus message bus, either the system-wide bus or a session bus. It can invoke methods on D-Bus objects or emit signals, and optionally wait for and print replies. The command is useful for scripting interactions with D-Bus services, debugging D-Bus interfaces, and testing service implementations. Arguments are type-annotated (string:, int32:, boolean:, etc.) to construct properly typed D-Bus messages. Common use cases include sending desktop notifications, querying system properties, and controlling media players or other desktop services that expose D-Bus interfaces.
How do I run a basic dbus-send example?
Run `dbus-send --session --dest=[org.freedesktop.Notifications] [/org/freedesktop/Notifications] [org.freedesktop.Notifications.GetCapabilities]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --session do in dbus-send?
Send to session bus.