Niri#

class ignis.services.niri.NiriService(*args: Any, **kwargs: Any)#

Niri IPC client.

Example usage:

from ignis.services.niri import NiriService

niri = NiriService.get_default()

# Get IDs of all workspaces
print([i.id for i in niri.workspaces])

# Get the ID of the active workspace on eDP-1
print([i.id for i in niri.workspaces if i.is_active and i.output == "eDP-1"])

# Get the currently active keyboard layout
print(niri.keyboard_layouts.current_name)

# Get the title of the active window
print(niri.active_window.title)
signal workspace_added#

Emitted when a new workspace has been added.

Parameters:

workspace (NiriWorkspace) -- The instance of the workspace.

gproperty is_available: bool#
  • read-only

Whether Niri IPC is available.

gproperty keyboard_layouts: NiriKeyboardLayouts#
  • read-only

The currenly configured keyboard layouts.

gproperty windows: list[NiriWindow]#
  • read-only

A list of windows.

gproperty active_window: NiriWindow#
  • read-only

The currenly focused window.

gproperty workspaces: list[NiriWorkspace]#
  • read-only

A list of workspaces.

gproperty active_output: str#
  • read-only

The currenly focused output.

send_command(cmd: dict | str) str#

Send a command to the Niri IPC.

Parameters:

cmd (dict | str) -- The command to send.

Return type:

str

Returns:

Response from Niri IPC.

Raises:

NiriIPCNotFoundError -- If Niri IPC is not found.

switch_kb_layout() None#

Switch to the next keyboard layout.

Return type:

None

switch_to_workspace(workspace_id: int) None#

Switch to a workspace by its ID.

Parameters:

workspace_id (int) -- The ID of the workspace to switch to.

Return type:

None

get_workspace_by_id(workspace_id: int) NiriWorkspace | None#

Get a workspace by its ID.

Parameters:

workspace_id (int) -- The ID of the workspace.

Return type:

NiriWorkspace | None

Returns:

The workspace instance, or None if the workspace with the given ID doesn't exist.

class ignis.services.niri.NiriKeyboardLayouts(*args: Any, **kwargs: Any)#

Configured keyboard layouts.

gproperty names: list#
  • read-only

XKB names of the configured layouts.

gproperty current_idx: int#
  • read-only

Index of the currently active layout in names.

gproperty current_name: str#
  • read-only

Name of the currently active layout.

switch_layout(layout: str) None#

Switch the keyboard layout.

Parameters:

layout (str) -- The layout to switch to (Next, Prev or a valid id)

Return type:

None

class ignis.services.niri.NiriWindow(*args: Any, **kwargs: Any)#

A window.

signal destroyed#

Emitted when the window has been destroyed.

gproperty id: int#
  • read-only

The unique ID of the window.

gproperty title: str#
  • read-only

The title of the window.

gproperty app_id: str#
  • read-only

Application ID of the window.

gproperty pid: int#
  • read-only

The PID of the window.

gproperty workspace_id: int#
  • read-only

The ID of the workspace where the window is placed.

gproperty is_focused: bool#
  • read-only

Whether the window is focused.

gproperty is_floating: bool#
  • read-only

Whether the window is floating.

close() None#

Close this window.

Return type:

None

focus() None#

Focus this window.

Return type:

None

toggle_fullscreen() None#

Toggle fullscreen on this window.

Return type:

None

toggle_floating() None#

Move the window between the floating and the tiling layout.

Return type:

None

class ignis.services.niri.NiriWorkspace(*args: Any, **kwargs: Any)#

A workspace.

signal destroyed#

Emitted when the workspace has been destroyed.

gproperty id: int#
  • read-only

The unique ID of the workspace.

gproperty idx: int#
  • read-only

The index of the workspace on its monitor.

gproperty name: str#
  • read-only

The name of the workspace.

gproperty output: str#
  • read-only

The name of the output on which the workspace is placed.

gproperty is_active: bool#
  • read-only

Whether the workspace is currently active on its output.

gproperty is_focused: bool#
  • read-only

Whether the workspace is currently focused.

gproperty active_window_id: int#
  • read-only

The ID of the active window on this workspace.

switch_to() None#

Switch to this workspace.

Return type:

None