Systemd#

class ignis.services.systemd.SystemdService(bus_type: Literal['session', 'system'] = 'session') None#

A service for managing systemd units through DBus.

The default behaviour is to operate on the systemd user bus. To operate on the system bus, use .get_default("system").

Example usage:

from ignis.services.systemd import SystemdService

systemd_session = SystemdService.get_default()

example_unit = systemd_session.get_unit("wluma.service")
example_unit.connect("notify::is-active", lambda x, y: print(example_unit.is_active))

systemd_system = SystemdService.get_default("system")

system_example_unit = systemd_system.get_unit("sshd.service")
system_example_unit.start()
classmethod get_default(bus_type: Literal['session', 'system'] = 'session') SystemdService#

Returns the default Service object for this process, creating it if necessary.

Parameters:

bus_type (Literal['session', 'system'], default: 'session') -- The bus type.

Return type:

SystemdService

Bus types:
  • session: current user session

  • system: entire system, requires interactive authorization when calling methods

property bus_type: Literal['session', 'system']#
  • read-only

The bus type.

property units: list[SystemdUnit]#
  • read-only

A list of all systemd units on the bus.

get_unit(unit: str) SystemdUnit#

Get SystemdUnit by the unit name.

Parameters:

unit (str) -- The name of the unit to get.

Return type:

SystemdUnit

Returns:

SystemdUnit

class ignis.services.systemd.SystemdUnit(object_path: str, bus_type: Literal['session', 'system'])#

An object tracking a single systemd unit.

property name: str#
  • read-only

The name of the unit.

property is_active: bool#
  • read-only

Whether the unit is active (running).

start() None#

Start this unit.

Return type:

None

stop() None#

Stop this unit.

Return type:

None

restart() None#

Restart this unit.

Return type:

None