Skip to main content

Python bindings for the Hyprland compositor.

Project description

Hyprpy

Python GitHub Release PyPI - Version AUR Version

Hyprpy is a library that provides python bindings for the Hyprland wayland compositor.

With Hyprpy you can very easily retrieve information about windows, workspaces and monitors in a running Hyprland instance. It also offers an event monitor, allowing you to write your own python callback functions which execute in response to Hyprland events.

Hyprpy uses unix sockets to communicate with Hyprland, making it fast and efficient.

Please check out the documentation! Hyprpy is fully typed and extensively documented. Happy hacking :sunglasses:

Quickstart

Installation

Pip

Install Hyprpy with pip by running:

pip install hyprpy

Arch Linux

Hyprpy is available in the AUR as python-hyprpy.

If you are using an AUR helper like paru simply install it by running:

paru -S python-hyprpy

Usage examples

from hyprpy import Hyprland

instance = Hyprland()


# Fetch active window and display information:
window = instance.get_active_window()
print(window.wm_class)
print(window.width)
print(window.position_x)


# Print information about the windows on the active workspace
workspace = instance.get_active_workspace()
for window in workspace.windows:
    print(f"{window.address}: {window.title} [{window.wm_class}]")


# Get the resolution of the first monitor
monitor = instance.get_monitor_by_id(0)
if monitor:
    print(f"{monitor.width} x {monitor.height}")


# Get all windows currently on the special workspace
special_workspace = instance.get_workspace_by_name("special")
if special_workspace:
    special_windows = special_workspace.windows
    for window in special_windows:
        print(window.title)


# Show a desktop notification every time we switch to workspace 6
from hyprpy.utils.shell import run_or_fail

def on_workspace_changed(sender, **kwargs):
    workspace_id = kwargs.get('workspace_id')
    if workspace_id == 6:
        run_or_fail(["notify-send", "We are on workspace 6."])

instance.signals.workspacev2.connect(on_workspace_changed)
instance.watch()

Development

Hyprpy is in active development! Please file an issue if you find any bugs or have a feature request.

Your contributions are greatly appreciated.

Roadmap

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hyprpy-0.2.1.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hyprpy-0.2.1-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file hyprpy-0.2.1.tar.gz.

File metadata

  • Download URL: hyprpy-0.2.1.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.11

File hashes

Hashes for hyprpy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 88615d869d0dcc56d29ffad685a652ffd935348c3d3bd8a97e68f4a913eb3bf0
MD5 3effb186f194ddfcb903259b7858dbbf
BLAKE2b-256 36c9ae481dea6ca032287fdb87c3afab1b9163e4840df5667d2d238c30d862f2

See more details on using hashes here.

File details

Details for the file hyprpy-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: hyprpy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.11

File hashes

Hashes for hyprpy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 22d2ae5cf29d88eafafe2de2758a222694a7822fa470a2cfaa845df8162026f6
MD5 257a176c157bacfd684f391ee5be1647
BLAKE2b-256 347fe462ee891e9fcd6d37defed3bc5e5d5b5724032a2044e877226e27be0da8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page