hyprpy


Namehyprpy JSON
Version 0.1.4 PyPI version JSON
download
home_page
SummaryPython bindings for the Hyprland compositor.
upload_time2023-08-16 13:01:44
maintainer
docs_urlNone
authorJulian Lobbes
requires_python>=3.7
license
keywords hyprland wayland compositor window manager
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Hyprpy

[Hyprpy](https://github.com/ulinja/hyprpy) is a library that provides python bindings for the [Hyprland](https://hyprland.org/) 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 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](https://hyprpy.lobbes.dev)!
Hyprpy is fully typed and extensively documented. Happy hacking :sunglasses:

## Quickstart

### Installation

```bash
pip install hyprpy
```

### Usage examples

```python
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 workspace_changed(sender, **kwargs):
    current_workspace = kwargs.get('active_workspace')
    if current_workspace.id == 6:
        run_or_fail(["notify-send", "We are on workspace 6."])

instance.signal_active_workspace_changed.connect(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

- [ ] dispatchers for components
- [ ] ???

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "hyprpy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "hyprland,wayland,compositor,window manager",
    "author": "Julian Lobbes",
    "author_email": "julian@lobbes.dev",
    "download_url": "https://files.pythonhosted.org/packages/54/85/da81ac0730cc6e2650c78ab1165f463bce4f0546ded2fb075ff6b604a7a4/hyprpy-0.1.4.tar.gz",
    "platform": null,
    "description": "# Hyprpy\n\n[Hyprpy](https://github.com/ulinja/hyprpy) is a library that provides python bindings for the [Hyprland](https://hyprland.org/) wayland compositor.\n\nWith Hyprpy you can very easily retrieve information about windows, workspaces and monitors\nin a running Hyprland instance.\nIt also offers an event monitor, allowing you to write your own callback functions which\nexecute in response to Hyprland events.\n\nHyprpy uses unix sockets to communicate with Hyprland, making it **fast** and **efficient**.\n\nPlease [check out the documentation](https://hyprpy.lobbes.dev)!\nHyprpy is fully typed and extensively documented. Happy hacking :sunglasses:\n\n## Quickstart\n\n### Installation\n\n```bash\npip install hyprpy\n```\n\n### Usage examples\n\n```python\nfrom hyprpy import Hyprland\n\ninstance = Hyprland()\n\n\n# Fetch active window and display information:\nwindow = instance.get_active_window()\nprint(window.wm_class)\nprint(window.width)\nprint(window.position_x)\n\n\n# Print information about the windows on the active workspace\nworkspace = instance.get_active_workspace()\nfor window in workspace.windows:\n    print(f\"{window.address}: {window.title} [{window.wm_class}]\")\n\n\n# Get the resolution of the first monitor\nmonitor = instance.get_monitor_by_id(0)\nif monitor:\n    print(f\"{monitor.width} x {monitor.height}\")\n\n\n# Get all windows currently on the special workspace\nspecial_workspace = instance.get_workspace_by_name(\"special\")\nif special_workspace:\n    special_windows = special_workspace.windows\n    for window in special_windows:\n        print(window.title)\n\n\n# Show a desktop notification every time we switch to workspace 6\nfrom hyprpy.utils.shell import run_or_fail\n\ndef workspace_changed(sender, **kwargs):\n    current_workspace = kwargs.get('active_workspace')\n    if current_workspace.id == 6:\n        run_or_fail([\"notify-send\", \"We are on workspace 6.\"])\n\ninstance.signal_active_workspace_changed.connect(workspace_changed)\ninstance.watch()\n```\n\n## Development\n\nHyprpy is in active development! Please file an issue if you find any bugs or have a feature request.\n\nYour contributions are greatly appreciated.\n\n### Roadmap\n\n- [ ] dispatchers for components\n- [ ] ???\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python bindings for the Hyprland compositor.",
    "version": "0.1.4",
    "project_urls": {
        "docs": "https://hyprpy.docs.lobbes.dev",
        "repo": "https://github.com/ulinja/hyprpy"
    },
    "split_keywords": [
        "hyprland",
        "wayland",
        "compositor",
        "window manager"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b998308e22f3d21ad8275ba20a43f0be40eef61ceebff5370c334e0041b2dfb1",
                "md5": "fa1dc28ed1bdc3d2afb7f5db736e6a38",
                "sha256": "f8f91ec6459fb7715c79f2fe70fc7f668f013c4e6634ce2e041da1a65d6e9984"
            },
            "downloads": -1,
            "filename": "hyprpy-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fa1dc28ed1bdc3d2afb7f5db736e6a38",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 23030,
            "upload_time": "2023-08-16T13:01:42",
            "upload_time_iso_8601": "2023-08-16T13:01:42.819578Z",
            "url": "https://files.pythonhosted.org/packages/b9/98/308e22f3d21ad8275ba20a43f0be40eef61ceebff5370c334e0041b2dfb1/hyprpy-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5485da81ac0730cc6e2650c78ab1165f463bce4f0546ded2fb075ff6b604a7a4",
                "md5": "8ef32109a41d185198e6eb6087c5e190",
                "sha256": "e75cc977bfc97753b20e4b3e60c830cb0fff04e7592bb97703a083ff444a681c"
            },
            "downloads": -1,
            "filename": "hyprpy-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "8ef32109a41d185198e6eb6087c5e190",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 19028,
            "upload_time": "2023-08-16T13:01:44",
            "upload_time_iso_8601": "2023-08-16T13:01:44.762766Z",
            "url": "https://files.pythonhosted.org/packages/54/85/da81ac0730cc6e2650c78ab1165f463bce4f0546ded2fb075ff6b604a7a4/hyprpy-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-16 13:01:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ulinja",
    "github_project": "hyprpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "hyprpy"
}
        
Elapsed time: 0.10058s