class DBus::Systemd::Logind::Manager

Constants

INHIBITOR_INDICES

inhibitor array index map as returned by ListInhibitors

INTERFACE

the logind manager object dbus interface

NODE

the logind manager object dbus node path

SEAT_INDICES

seat array index map as returned by ListSeats

SESSION_INDICES

session array index map as returned by ListSessions

USER_INDICES

user array index map as returned by ListUsers

Attributes

service[R]

@return [DBus::Service] @api private

Public Class Methods

new(bus = Systemd::Helpers.system_bus) click to toggle source

Create a logind manager dbus proxy object

@param bus [DBus::SystemBus, DBus::SessionBus] dbus instance

# File lib/dbus/systemd/logind/manager.rb, line 83
def initialize(bus = Systemd::Helpers.system_bus)
  @service = bus.service(Logind::SERVICE)
  @object = @service.object(NODE)
  @object.default_iface = INTERFACE
  @object.introspect
end

Public Instance Methods

get_seat_by_path(path) click to toggle source

get seat object from dbus node path

@param path [String] seat dbus node path @return [DBus::Systemd::Logind::Seat] logind seat object

# File lib/dbus/systemd/logind/manager.rb, line 112
def get_seat_by_path(path)
  obj = @service.object(path)
                .tap(&:introspect)
  Seat.new(obj.Get(Seat::INTERFACE, 'Id').first, self)
end
get_session_by_path(path) click to toggle source

get session object by dbus node path

@param path [String] session dbus node path @return [DBus::Systemd::Logind::Session] logind session object

# File lib/dbus/systemd/logind/manager.rb, line 149
def get_session_by_path(path)
  obj = @service.object(path)
                .tap(&:introspect)
  Session.new(obj.Get(Session::INTERFACE, 'Id').first, self)
end
get_user_by_path(path) click to toggle source

get user dbus object from dbus node path

@param path [String] dbus node path for user @return [DBus::Systemd::Logind::User] logind user dbus object

# File lib/dbus/systemd/logind/manager.rb, line 186
def get_user_by_path(path)
  obj = @service.object(path)
                .tap(&:introspect)
  User.new(obj.Get(User::INTERFACE, 'Id').first, self)
end
map_seat(seat_array) click to toggle source

map seat array to named field hash

@param seat_array [Array] seat array as returned from ListSeats @return [Hash] mapped array as hash

# File lib/dbus/systemd/logind/manager.rb, line 123
def map_seat(seat_array)
  Systemd::Helpers.map_array(seat_array, SEAT_INDICES)
end
map_session(session_array) click to toggle source

convert session array to mapped hash

@param session_array [Array] session array as returned by ListSessions @return [Hash] mapped session property hash

# File lib/dbus/systemd/logind/manager.rb, line 160
def map_session(session_array)
  Systemd::Helpers.map_array(session_array, SESSION_INDICES)
end
map_user(user_array) click to toggle source

convert user array to hash with mapped properties

@param user_array [Array] user array as returned by ListUsers @return [Hash] hash with mapped user properties

# File lib/dbus/systemd/logind/manager.rb, line 197
def map_user(user_array)
  Systemd::Helpers.map_array(user_array, USER_INDICES)
end
seat(id) click to toggle source

get seat object

@param id [String] seat id (e.g. 'seat0') @return [DBus::Systemd::Logind::Seat] logind seat object

# File lib/dbus/systemd/logind/manager.rb, line 103
def seat(id)
  Seat.new(id, self)
end
seats() click to toggle source

get mapped list of seats

@return [Array] array of mapped seat hashes

# File lib/dbus/systemd/logind/manager.rb, line 94
def seats
  self.ListSeats.first.map { |s| map_seat(s) }
end
session(id) click to toggle source

dbus session object by id

@param id [String] session id @return [DBus::Systemd::Logind::Session] logind session object

# File lib/dbus/systemd/logind/manager.rb, line 140
def session(id)
  Session.new(id, self)
end
sessions() click to toggle source

array of property-mapped seat hashes

@return [Array] array of seat-property hashes

# File lib/dbus/systemd/logind/manager.rb, line 131
def sessions
  self.ListSessions.first.map { |s| map_session(s) }
end
user(id) click to toggle source

get user dbus object

@param id [Integer] user id @return [DBus::Systemd::Logind::User] logind user dbus object

# File lib/dbus/systemd/logind/manager.rb, line 177
def user(id)
  User.new(id, self)
end
users() click to toggle source

get logind users

@return [Array] array of mapped logind user property hashes

# File lib/dbus/systemd/logind/manager.rb, line 168
def users
  self.ListUsers.first.map { |u| map_user(u) }
end