Class: DBus::Systemd::Logind::Manager
- Inherits:
-
Object
- Object
- DBus::Systemd::Logind::Manager
- Includes:
- Mixin::MethodMissing, Mixin::Properties
- Defined in:
- lib/dbus/systemd/logind/manager.rb
Constant Summary collapse
- NODE =
the logind manager object dbus node path
'/org/freedesktop/login1'.freeze
- INTERFACE =
the logind manager object dbus interface
'org.freedesktop.login1.Manager'.freeze
- SESSION_INDICES =
session array index map as returned by ListSessions
{ id: 0, user_id: 1, user_name: 2, seat_id: 3, object_path: 4 }.freeze
- USER_INDICES =
user array index map as returned by ListUsers
{ id: 0, name: 1, object_path: 2 }.freeze
- SEAT_INDICES =
seat array index map as returned by ListSeats
{ id: 0, object_path: 1 }.freeze
- INHIBITOR_INDICES =
inhibitor array index map as returned by ListInhibitors
{ what: 0, who: 1, why: 2, mode: 3, user_id: 4, process_id: 5 }.freeze
Instance Attribute Summary collapse
- #service ⇒ DBus::Service readonly private
Attributes included from Mixin::MethodMissing
Instance Method Summary collapse
-
#get_seat_by_path(path) ⇒ DBus::Systemd::Logind::Seat
get seat object from dbus node path.
-
#get_session_by_path(path) ⇒ DBus::Systemd::Logind::Session
get session object by dbus node path.
-
#get_user_by_path(path) ⇒ DBus::Systemd::Logind::User
get user dbus object from dbus node path.
-
#initialize(bus = Systemd::Helpers.system_bus) ⇒ Manager
constructor
Create a logind manager dbus proxy object.
-
#map_seat(seat_array) ⇒ Hash
map seat array to named field hash.
-
#map_session(session_array) ⇒ Hash
convert session array to mapped hash.
-
#map_user(user_array) ⇒ Hash
convert user array to hash with mapped properties.
-
#seat(id) ⇒ DBus::Systemd::Logind::Seat
get seat object.
-
#seats ⇒ Array
get mapped list of seats.
-
#session(id) ⇒ DBus::Systemd::Logind::Session
dbus session object by id.
-
#sessions ⇒ Array
array of property-mapped seat hashes.
-
#user(id) ⇒ DBus::Systemd::Logind::User
get user dbus object.
-
#users ⇒ Array
get logind users.
Methods included from Mixin::Properties
Methods included from Mixin::MethodMissing
#method_missing, #respond_to_missing?
Constructor Details
#initialize(bus = Systemd::Helpers.system_bus) ⇒ Manager
Create a logind manager dbus proxy object
83 84 85 86 87 88 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class DBus::Systemd::Mixin::MethodMissing
Instance Attribute Details
#service ⇒ DBus::Service (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
77 78 79 |
# File 'lib/dbus/systemd/logind/manager.rb', line 77 def service @service end |
Instance Method Details
#get_seat_by_path(path) ⇒ DBus::Systemd::Logind::Seat
get seat object from dbus node path
112 113 114 115 116 |
# 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) ⇒ DBus::Systemd::Logind::Session
get session object by dbus node path
149 150 151 152 153 |
# 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) ⇒ DBus::Systemd::Logind::User
get user dbus object from dbus node path
186 187 188 189 190 |
# 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) ⇒ Hash
map seat array to named field hash
123 124 125 |
# 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) ⇒ Hash
convert session array to mapped hash
160 161 162 |
# 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) ⇒ Hash
convert user array to hash with mapped properties
197 198 199 |
# 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) ⇒ DBus::Systemd::Logind::Seat
get seat object
103 104 105 |
# File 'lib/dbus/systemd/logind/manager.rb', line 103 def seat(id) Seat.new(id, self) end |
#seats ⇒ Array
get mapped list of seats
94 95 96 |
# File 'lib/dbus/systemd/logind/manager.rb', line 94 def seats self.ListSeats.first.map { |s| map_seat(s) } end |
#session(id) ⇒ DBus::Systemd::Logind::Session
dbus session object by id
140 141 142 |
# File 'lib/dbus/systemd/logind/manager.rb', line 140 def session(id) Session.new(id, self) end |
#sessions ⇒ Array
array of property-mapped seat hashes
131 132 133 |
# File 'lib/dbus/systemd/logind/manager.rb', line 131 def sessions self.ListSessions.first.map { |s| map_session(s) } end |
#user(id) ⇒ DBus::Systemd::Logind::User
get user dbus object
177 178 179 |
# File 'lib/dbus/systemd/logind/manager.rb', line 177 def user(id) User.new(id, self) end |
#users ⇒ Array
get logind users
168 169 170 |
# File 'lib/dbus/systemd/logind/manager.rb', line 168 def users self.ListUsers.first.map { |u| map_user(u) } end |