Hyprland#

class ignis.services.hyprland.HyprlandService(*args: Any, **kwargs: Any)#

Hyprland IPC client.

Raises:

HyprlandIPCNotFoundError -- If Hyprland IPC is not found.

Note

The contents of dict properties are not described here. To find out their contents just print them into the terminal.

>>> print(hyprland.workspaces)
[
    {
        "id": 1,
        "name": "1",
        "monitor": "DP-1",
        "monitorID": 1,
        "windows": 1,
        "hasfullscreen": False,
        "lastwindow": "0x561dc35d2e80",
        "lastwindowtitle": "hyprland.py - ignis - Visual Studio Code",
    },
    {
        "id": 10,
        "name": "10",
        "monitor": "HDMI-A-1",
        "monitorID": 0,
        "windows": 1,
        "hasfullscreen": False,
        "lastwindow": "0x561dc3845f30",
        "lastwindowtitle": "Type hints cheat sheet - mypy 1.11.2 documentation — Mozilla Firefox",
    },
]
>>> print(hyprland.active_window)
{
    "address": "0x561dc35d2e80",
    "mapped": True,
    "hidden": False,
    "at": [1942, 22],
    "size": [1876, 1036],
    "workspace": {"id": 1, "name": "1"},
    "floating": False,
    "pseudo": False,
    "monitor": 1,
    "class": "code-url-handler",
    "title": "hyprland.py - ignis - Visual Studio Code",
    "initialClass": "code-url-handler",
    "initialTitle": "Visual Studio Code",
    "pid": 1674,
    "xwayland": False,
    "pinned": False,
    "fullscreen": 0,
    "fullscreenClient": 0,
    "grouped": [],
    "tags": [],
    "swallowing": "0x0",
    "focusHistoryID": 0,
}

Example usage:

from ignis.services.hyprland import HyprlandService

hyprland = HyprlandService.get_default()

print(hyprland.workspaces)
print(hyprland.kb_layout)

hyprland.connect("notify::kb-layout", lambda x, y: print(hyprland.kb_layout))
property workspaces: list[dict[str, Any]]#
  • read-only

A list of workspaces.

property active_workspace: dict[str, Any]#
  • read-only

The currently active workspace.

property kb_layout: str#
  • read-only

The currenly active keyboard layout.

property active_window: dict[str, Any]#
  • read-only

The currenly focused window.

send_command(cmd: str) str#

Send a command to the Hyprland IPC. Supports the same commands as hyprctl. If you want to receive the response in JSON format, use this syntax: j/COMMAND.

Parameters:

cmd (str) -- The command to send.

Return type:

str

Returns:

Response from Hyprland IPC.

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