ruby-dbus-wrapper

Wrapper for Ruby D-Bus client providing some useful high-level methods.

Installation

Step 1: Add Ruby D-Bus gem to your Gemfile

You have to manually add your Ruby D-Bus bindings to the Gemfile because there are two gems that can be used and it's up to you which one you choose: original ruby-dbus or EventMachine-powered em-ruby-dbus.

If you are unsure or want to use the original ruby-dbus, add the following line to your Gemfile:

gem 'ruby-dbus'

If you want to use EventMachine version, add the following line to your Gemfile:

gem 'em-ruby-dbus'

Step 2: Add this gem to your Gemfile

Just add the following line to your Gemfile:

gem 'ruby-dbus-wrapper'

Usage

Right now this gem provides two methods, that allows to invoke method calls or watch signals without creating proxy objects.

Method calls

conn = DBus::SessionBus.instance
bus = DBus::Wrapper::Bus.new(conn)

# Without parameters
bus.method_call("org.freedesktop.DBus", "/", "org.freedesktop.DBus", "ListNames") do |message| 
  # do something
end

# With parameters
bus.method_call("another.destination", "/", "some.Interface", "SomeMember", [["s", "First param"], ["a{ss}", { "Second" => "Param"}]]) do |message| 
  # do something
end

main = DBus::Main.new
main << conn
main.run

The arguments are: destination, path, interface, member, params = nil, &callback

Signal monitoring

conn = DBus::SessionBus.instance
bus = DBus::Wrapper::Bus.new(conn)

# Without parameters
bus.monitor_signal("org.freedesktop.DBus", nil, "org.freedesktop.DBus", "NameOwnerChanged") do |message|
  # do something
end

main = DBus::Main.new
main << conn
main.run

The arguments are: sender, path, interface, member, &callback

License

MIT

Author

(c) 2014 Marcin Lewandowski