Components API¶
This is the component API reference. Here you will find the nitty-gritty details about Hyprpy component objects.
For a more general overview on how to use components, take a look at the Components guide.
Instance¶
The central Instance class for interfacing with Hyprland.
This class acts as the root for accessing other components like workspaces, windows, and monitors, and offers capabilities to listen to events and signals emitted by the underlying Hyprland system.
- class Instance(signature: str | None = None)¶
Bases:
objectRepresents an active Hyprland instance.
The Instance class is a primary interface for interacting with the Hyprland system. It provides methods for accessing windows, workspaces, and monitors, as well as emitting signals based on events in the Hyprland environment.
- Seealso:
- signature: str¶
Instance signature of the Hyprland instance.
- event_socket: EventSocket¶
The Hyprland event socket for this instance.
- command_socket: CommandSocket¶
The Hyprland command socket for this instance.
- signals: InstanceSignalCollection¶
The
InstanceSignalCollectionfor this instance.
- signal_workspace_created: Signal¶
🚫 Deprecated since v0.2.0
This signal has been moved to
createworkspaceand will be removed in future versions of hyprpy.Signal emitted when a new workspace gets created. Sends
created_workspace_id, theidof the created workspace, as signal data.
- signal_workspace_destroyed: Signal¶
🚫 Deprecated since v0.2.0
This signal has been moved to
destroyworkspaceand will be removed in future versions of hyprpy.Signal emitted when an existing workspace gets destroyed. Sends
destroyed_workspace_id, theidof the destroyed workspace, as signal data.
- signal_active_workspace_changed: Signal¶
🚫 Deprecated since v0.2.0
This signal has been moved to
workspaceand will be removed in future versions of hyprpy.Signal emitted when the focus changes to another workspace. Sends
active_workspace_id, theidof the now active workspace, as signal data.
- signal_window_created: Signal¶
🚫 Deprecated since v0.2.0
This signal has been moved to
openwindowand will be removed in future versions of hyprpy.Signal emitted when a new window gets created. Sends
created_window_address, theaddressof the newly created window, as signal data.
- signal_window_destroyed: Signal¶
🚫 Deprecated since v0.2.0
This signal has been moved to
closewindowand will be removed in future versions of hyprpy.Signal emitted when an existing window gets destroyed. Sends
destroyed_window_address, theaddressof the destroyed window, as signal data.
- signal_active_window_changed: Signal¶
🚫 Deprecated since v0.2.0
This signal has been moved to
activewindowand will be removed in future versions of hyprpy.Signal emitted when the focus changes to another window. Sends
active_window_address, theaddressof the now active window, as signal data.
- dispatch(arguments: list[str]) str | None¶
Runs a generic dispatcher command with the given arguments and returns
Noneon success or a string indicating errors.See the Hyprland Wiki for a list of available commands.
Example:
from hyprpy import Hyprland instance = Hyprland() instance.dispatch(["cyclenext", "prev"])
- Parameters:
arguments (list[str]) – A list of strings containing the arguments of the dispatch command.
- Returns:
None if the command succeeded, otherwise a string indicating errors.
- Return type:
str or None
- get_windows() List[Window]¶
Returns all
Windows currently managed by the instance.- Returns:
A list containing
Windowobjects.
- get_window_by_address(address: str) Window | None¶
Retrieves the
Windowwith the specifiedaddress.The
addressmust be a valid hexadecimal string.- Returns:
The
Windowif it exists, orNoneotherwise.- Raises:
TypeErrorifaddressis not a string.- Raises:
ValueErrorifaddressis not a valid hexadecimal string.
- get_active_window() Window¶
Returns the currently active
Window.- Returns:
The currently active
Window.
- get_workspaces() List[Workspace]¶
Returns all
Workspaces currently managed by the instance.- Returns:
A list containing
Workspaces.
- get_workspace_by_id(id: int) Workspace | None¶
Retrieves the
Workspacewith the specifiedid.- Returns:
The
Workspaceif it exists, orNoneotherwise.- Raises:
TypeErrorifidis not an integer.
- get_active_workspace() Workspace¶
Retrieves the currently active
Workspace.- Returns:
The currently active
Workspace.
- get_workspace_by_name(name: int) Workspace | None¶
Retrieves the
Workspacewith the specifiedname.- Returns:
The
Workspaceif it exists, orNoneotherwise.- Raises:
TypeErrorifnameis not a string.
- get_monitors() List[Monitor]¶
Returns all
Monitors currently managed by the instance.- Returns:
A list containing
Monitors.
- get_monitor_by_id(id: int) Monitor | None¶
Retrieves the
Monitorwith the specifiedid.- Returns:
The
Monitorif it exists, orNoneotherwise.- Raises:
TypeErrorifidis not an integer.
- get_monitor_by_name(name: str) Monitor | None¶
Retrieves the
Monitorwith the specifiedname.- Returns:
The
Monitorif it exists, orNoneotherwise.- Raises:
TypeErrorifnameis not a string.- Raises:
ValueErrorifnameis an empty string.
- watch() None¶
Continuosly monitors the
EventSocketand emits appropriateSignals when events are detected.This is a blocking method which runs indefinitely. Signals are continuosly emitted, as soon as Hyprland events are detected.
- Seealso:
Window¶
Window objects represent individual windows in Hyprland.
- class Window(window_data: dict, instance: Instance)¶
Bases:
objectRepresents a window in the Hyprland compositor.
- address: str¶
String representation of a hexadecimal number, unique identifier for the window.
- is_mapped: bool¶
Unknown.
Unknown.
- position_x: int¶
Absolute X-coordinate of the window on the monitor (in pixels).
- position_y: int¶
Absolute Y-coordinate of the window on the monitor (in pixels).
- width: int¶
Width of the window (in pixels).
- height: int¶
Height of the window (in pixels).
- workspace_id: int¶
Numeric ID of the workspace which the window is on.
- workspace_name: str¶
Name of the workspace which the window is on.
- is_floating: bool¶
Whether or not this is a floating window.
- monitor_id: int¶
Numeric ID of the monitor which the window is on.
- wm_class: str¶
Window manager class assigned to this window.
- title: str¶
Current title of the window.
- initial_wm_class: str¶
Window manager class when the window was created.
- initial_title: str¶
Title when the window was created.
- pid: int¶
Process ID of the process the window is assigned to.
- is_xwayland: bool¶
Whether or not the window is using xwayland to be displayed.
- is_pinned: bool¶
Unknown.
- is_fullscreen: int¶
Whether or not the window is in fullscreen mode.
Workspace¶
Workspace objects represent individual workspaces in Hyprland.
- class Workspace(workspace_data: dict, instance: Instance)¶
Bases:
objectRepresents a workspace in Hyprland.
- id: int¶
Numeric ID of the workspace.
- name: str¶
Name assigned to the workspace.
- monitor_name: str¶
Name of the monitor which this workspace is on.
- last_window_address: str¶
Address string of the most recently active window on the workspace.
- last_window_title: str¶
Title of the most recently active window on the workspace.
- window_count: int¶
Number of windows placed in the workspace.
- has_fullscreen: bool¶
True if at least one window in the workspace is in fullscreen mode.
- property last_window_address_as_int: int¶
The integer representation of the workspace’s
last_window_addressproperty.
Monitor¶
Monitor objects represent monitors in Hyprland.
- class Monitor(monitor_data: str, instance: Instance)¶
Bases:
objectRepresents a monitor within Hyprland.
- id: int¶
Numeric ID of the monitor.
- name: str¶
Name of the monitor.
- description: str¶
Manufacturer’s name.
- make: str¶
Model number of the monitor.
- model: str¶
Composite string of make, name and model.
- serial: str¶
Unknown.
- width: int¶
Width of the monitor (in pixels).
- height: int¶
Height of the monitor (in pixels).
- refresh_rate: float¶
Refresh rate of the monitor (in Hz).
- position_x: int¶
Unknown.
- position_y: int¶
Unknown.
- active_workspace_id: int¶
Numeric ID of the workspace currently active on the monitor.
- active_workspace_name: str¶
Assigned name of the workspace currently active on the monitor.
- reserved: List[int]¶
Unknown.
- scale: float¶
Unknown.
- transform: int¶
Unknown.
- is_focused: bool¶
Whether or not the currently focused window is on this monitor.
- uses_dpms: bool¶
Whether or not the monitor uses DPMS.
- vrr: bool¶
Unknown.
Instance Signals¶
The list of signals emitted by hyprpy, which covers all events sent by Hyprland.
- class InstanceSignalCollection¶
Bases:
objectThe collection of Hyprland signals emitted by an
Instance.- activelayout: Signal¶
Emits the following Signal Data when a keyboard’s layout is changed:
Name
Type
Description
keyboard_namestrName of the keyboard
layout_namestrName of the newly active layout
- activespecial: Signal¶
Emits the following Signal Data when the special workspace on a monitor changes:
Name
Type
Description
workspace_namestrorNonenameof the workspace ("special:special") if the special workspace was created, andNoneif it was destroyedmonitor_namestrnameof the monitor
- activespecialv2: Signal¶
Emits the following Signal Data when the special workspace on a monitor changes:
Name
Type
Description
workspace_idintorNoneidof the workspace (-99) if the special workspace was created, andNoneif it was destroyedworkspace_namestrorNonenameof the workspace ("special:special") if the special workspace was created, andNoneif it was destroyedmonitor_namestrnameof the monitor
- activewindow: Signal¶
Emits the following Signal Data when the active window is changed:
Name
Type
Description
window_classstrThe newly active window’s
wm_classwindow_titlestrName of the newly active window’s
title
- activewindowv2: Signal¶
Emits the following Signal Data when the active window is changed:
Name
Type
Description
window_addressstrThe newly active Window’s
address
- changefloatingmode: Signal¶
Emits the following Signal Data when a window’s floating state changes:
Name
Type
Description
window_addressstraddressof the windowis_floatingboolTrueif the window is floating, andFalseotherwise
- closelayer: Signal¶
Emits the following Signal Data when a layerSurface is unmapped:
Name
Type
Description
namespacestrUnknown.
- closewindow: Signal¶
Emits the following Signal Data when a window is closed:
Name
Type
Description
window_addressstraddressof the closed window
- createworkspace: Signal¶
Emits the following Signal Data when a workspace is created:
Name
Type
Description
workspace_namestrnameof the created workspace
- createworkspacev2: Signal¶
Emits the following Signal Data when a workspace is created:
Name
Type
Description
workspace_idintidof the created workspaceworkspace_namestrnameof the created workspace
- destroyworkspace: Signal¶
Emits the following Signal Data when a workspace is destroyed:
Name
Type
Description
workspace_namestrnameof the destroyed workspace
- destroyworkspacev2: Signal¶
Emits the following Signal Data when a workspace is destroyed:
Name
Type
Description
workspace_idintidof the destroyed workspaceworkspace_namestrnameof the destroyed workspace
- focusedmon: Signal¶
Emits the following Signal Data when the active monitor changes:
Name
Type
Description
monitor_namestrnameof the newly active monitorworkspace_namestrnameof the newly active workspace
- focusedmonv2: Signal¶
Emits the following Signal Data when the active monitor changes:
Name
Type
Description
monitor_namestrnameof the newly active monitorworkspace_idintidof the workspace which is now active
- fullscreen: Signal¶
Emits the following Signal Data when the fullscreen state of any window changes:
Name
Type
Description
is_fullscreenboolTrueif fullscreen mode was activated, andFalseif fullscreen mode was deactivated
- ignoregrouplock: Signal¶
Emits the following Signal Data when
ignoregrouplockis toggled:Name
Type
Description
ignore_group_lock_enabledboolTrueifignoregrouplockwas activated, andFalseif it was deactivated
- lockgroups: Signal¶
Emits the following Signal Data when
lockgroupsis toggled:Name
Type
Description
lock_groups_enabledboolTrueiflockgroupswas activated, andFalseif it was deactivated
- monitoradded: Signal¶
Emits the following Signal Data when a monitor is added:
Name
Type
Description
monitor_namestrnameof the newly added monitor
- monitoraddedv2: Signal¶
Emits the following Signal Data when a monitor is added:
Name
Type
Description
monitor_idintidof the newly added monitormonitor_namestrnameof the newly added monitormonitor_descriptionstrdescriptionof the newly added monitor
- monitorremoved: Signal¶
Emits the following Signal Data when a monitor is removed:
Name
Type
Description
monitor_namestrnameof the removed monitor
- moveintogroup: Signal¶
Emits the following Signal Data when a window is merged into a group:
Name
Type
Description
window_addressstraddressof the merged window
- moveoutofgroup: Signal¶
Emits the following Signal Data when a window is removed from a group:
Name
Type
Description
window_addressstraddressof the removed window
- movewindow: Signal¶
Emits the following Signal Data when a window is moved to a workspace:
Name
Type
Description
window_addressstraddressof the window which was movedworkspace_namestrnameof the workspace the window was moved to
- movewindowv2: Signal¶
Emits the following Signal Data when a window is moved to a workspace:
Name
Type
Description
window_addressstraddressof the window which was movedworkspace_namestrnameof the workspace the window was moved toworkspace_idintidof the workspace the window was moved to
- moveworkspace: Signal¶
Emits the following Signal Data when a workspace is moved to a different monitor:
Name
Type
Description
workspace_namestrnameof the workspace which was movedmonitor_namestrnameof the monitor which the workspace was moved to
- moveworkspacev2: Signal¶
Emits the following Signal Data when a workspace is moved to a different monitor:
Name
Type
Description
workspace_idintidof the workspace which was movedworkspace_namestrnameof the workspace which was movedmonitor_namestrnameof the monitor which the workspace was moved to
- openlayer: Signal¶
Emits the following Signal Data when a layerSurface is mapped:
Name
Type
Description
namespacestrUnknown.
- openwindow: Signal¶
Emits the following Signal Data when a window is opened:
Name
Type
Description
window_addressstraddressof the opened windowworkspace_namestrnameof the workspace on which the window was openedwindow_classstrThe opened window’s
wm_classwindow_titlestrName of the opened window’s
title
- pin: Signal¶
Emits the following Signal Data when a window is pinned or unpinned:
Name
Type
Description
window_addressstraddressof the pinned/unpinned windowis_pinnedboolTrueif the window was pinned, andFalseif it was unpinned.
- renameworkspace: Signal¶
Emits the following Signal Data when a workspace is renamed:
Name
Type
Description
workspace_idintidof the workspace which was renamednew_namestrNew
nameof the workspace
- screencast: Signal¶
Emits the following Signal Data when the screencopy state of a client changes:
Name
Type
Description
screencast_enabledboolTrueif the screencast was enabled, andFalseif it was disabledscreencast_typestr"MONITOR"if the screencast was enabled for a monitor, and"WINDOW"if it was enabled for a window
- submap: Signal¶
Emits the following Signal Data when a keybind submap changes:
Name
Type
Description
submap_namestrorNoneName of the new submap, or
Noneif the default submap is now active
- togglegroup: Signal¶
Emits the following Signal Data when the togglegroup command is used:
Name
Type
Description
group_is_activeboolTrueif the group was created, andFalseif it was destroyedwindow_addresseslist[str]listofaddresses of the windows in the group
- urgent: Signal¶
Emits the following Signal Data when a window requests an urgent state:
Name
Type
Description
window_addressstraddressof the window requesting urgent state
- windowtitle: Signal¶
Emits the following Signal Data when the title of a window changes:
Name
Type
Description
window_addressstraddressof the window whose title changed
- windowtitlev2: Signal¶
Emits the following Signal Data when the title of a window changes:
Name
Type
Description
window_addressstraddressof the window whose title changedwindow_titlestrtitleof the window whose title changed
Misc.¶
Common classes, shared among different components.
- exception ParentNotFoundException¶
Bases:
ExceptionRaised when a component’s parent could not be found.
This exception may occur due to programming errors or race conditions, for example when a
hyprpy.components.windows.Windowknows the ID of thehyprpy.components.workspaces.Workspaceit is on, but no workspace with that ID exists.