# 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_id = kwargs.get('active_workspace_id')
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
- [ ] include [dispatchers in components API](https://github.com/ulinja/hyprpy/issues/11)
Raw data
{
"_id": null,
"home_page": null,
"name": "hyprpy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "hyprland, wayland, compositor, window manager",
"author": "Julian Lobbes",
"author_email": "julian@lobbes.dev",
"download_url": "https://files.pythonhosted.org/packages/ff/1c/d089aa6e259ffa1bf1b061adcc74c22d37976fd059d50ccce381ddf148c5/hyprpy-0.1.7.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_id = kwargs.get('active_workspace_id')\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- [ ] include [dispatchers in components API](https://github.com/ulinja/hyprpy/issues/11)\n",
"bugtrack_url": null,
"license": null,
"summary": "Python bindings for the Hyprland compositor.",
"version": "0.1.7",
"project_urls": {
"docs": "https://hyprpy.lobbes.dev/",
"repo": "https://github.com/ulinja/hyprpy"
},
"split_keywords": [
"hyprland",
" wayland",
" compositor",
" window manager"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cf6893e16a2ec4c5cbdd633e603f827d1dce4dfd0ed6b4eb17f295d74dfe56e5",
"md5": "768063834d7c21b32bb396b45e4d2101",
"sha256": "815dd2776c7fbaed386137432d7faaeaae2fb37a72ed040aac67faf642ee2703"
},
"downloads": -1,
"filename": "hyprpy-0.1.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "768063834d7c21b32bb396b45e4d2101",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 23945,
"upload_time": "2024-05-25T12:17:57",
"upload_time_iso_8601": "2024-05-25T12:17:57.373774Z",
"url": "https://files.pythonhosted.org/packages/cf/68/93e16a2ec4c5cbdd633e603f827d1dce4dfd0ed6b4eb17f295d74dfe56e5/hyprpy-0.1.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ff1cd089aa6e259ffa1bf1b061adcc74c22d37976fd059d50ccce381ddf148c5",
"md5": "c403b4d4da43546128b52335a5a95f10",
"sha256": "763c3d8a11d599ab9493b39d86fd84a6332e77b6ebe0b989d7d182794401bde8"
},
"downloads": -1,
"filename": "hyprpy-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "c403b4d4da43546128b52335a5a95f10",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 19887,
"upload_time": "2024-05-25T12:18:05",
"upload_time_iso_8601": "2024-05-25T12:18:05.972990Z",
"url": "https://files.pythonhosted.org/packages/ff/1c/d089aa6e259ffa1bf1b061adcc74c22d37976fd059d50ccce381ddf148c5/hyprpy-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-25 12:18:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ulinja",
"github_project": "hyprpy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "alabaster",
"specs": [
[
"==",
"0.7.13"
]
]
},
{
"name": "annotated-types",
"specs": [
[
"==",
"0.5.0"
]
]
},
{
"name": "Babel",
"specs": [
[
"==",
"2.12.1"
]
]
},
{
"name": "bleach",
"specs": [
[
"==",
"6.0.0"
]
]
},
{
"name": "build",
"specs": [
[
"==",
"0.10.0"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2023.7.22"
]
]
},
{
"name": "cffi",
"specs": [
[
"==",
"1.15.1"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.2.0"
]
]
},
{
"name": "cryptography",
"specs": [
[
"==",
"41.0.3"
]
]
},
{
"name": "docutils",
"specs": [
[
"==",
"0.20.1"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.4"
]
]
},
{
"name": "imagesize",
"specs": [
[
"==",
"1.4.1"
]
]
},
{
"name": "importlib-metadata",
"specs": [
[
"==",
"6.8.0"
]
]
},
{
"name": "jaraco.classes",
"specs": [
[
"==",
"3.3.0"
]
]
},
{
"name": "jeepney",
"specs": [
[
"==",
"0.8.0"
]
]
},
{
"name": "Jinja2",
"specs": [
[
"==",
"3.1.2"
]
]
},
{
"name": "keyring",
"specs": [
[
"==",
"24.2.0"
]
]
},
{
"name": "markdown-it-py",
"specs": [
[
"==",
"3.0.0"
]
]
},
{
"name": "MarkupSafe",
"specs": [
[
"==",
"2.1.3"
]
]
},
{
"name": "mdurl",
"specs": [
[
"==",
"0.1.2"
]
]
},
{
"name": "more-itertools",
"specs": [
[
"==",
"10.1.0"
]
]
},
{
"name": "packaging",
"specs": [
[
"==",
"23.1"
]
]
},
{
"name": "pkginfo",
"specs": [
[
"==",
"1.9.6"
]
]
},
{
"name": "pycparser",
"specs": [
[
"==",
"2.21"
]
]
},
{
"name": "pydantic",
"specs": [
[
"==",
"2.1.1"
]
]
},
{
"name": "pydantic_core",
"specs": [
[
"==",
"2.4.0"
]
]
},
{
"name": "Pygments",
"specs": [
[
"==",
"2.16.1"
]
]
},
{
"name": "pyproject_hooks",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "readme-renderer",
"specs": [
[
"==",
"40.0"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.31.0"
]
]
},
{
"name": "requests-toolbelt",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "rfc3986",
"specs": [
[
"==",
"2.0.0"
]
]
},
{
"name": "rich",
"specs": [
[
"==",
"13.5.2"
]
]
},
{
"name": "SecretStorage",
"specs": [
[
"==",
"3.3.3"
]
]
},
{
"name": "six",
"specs": [
[
"==",
"1.16.0"
]
]
},
{
"name": "snowballstemmer",
"specs": [
[
"==",
"2.2.0"
]
]
},
{
"name": "Sphinx",
"specs": [
[
"==",
"7.1.2"
]
]
},
{
"name": "sphinx-press-theme",
"specs": [
[
"==",
"0.8.0"
]
]
},
{
"name": "sphinxcontrib-applehelp",
"specs": [
[
"==",
"1.0.6"
]
]
},
{
"name": "sphinxcontrib-devhelp",
"specs": [
[
"==",
"1.0.4"
]
]
},
{
"name": "sphinxcontrib-htmlhelp",
"specs": [
[
"==",
"2.0.3"
]
]
},
{
"name": "sphinxcontrib-jsmath",
"specs": [
[
"==",
"1.0.1"
]
]
},
{
"name": "sphinxcontrib-qthelp",
"specs": [
[
"==",
"1.0.5"
]
]
},
{
"name": "sphinxcontrib-serializinghtml",
"specs": [
[
"==",
"1.1.7"
]
]
},
{
"name": "tomli",
"specs": [
[
"==",
"2.0.1"
]
]
},
{
"name": "twine",
"specs": [
[
"==",
"4.0.2"
]
]
},
{
"name": "typing_extensions",
"specs": [
[
"==",
"4.7.1"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.0.4"
]
]
},
{
"name": "webencodings",
"specs": [
[
"==",
"0.5.1"
]
]
},
{
"name": "zipp",
"specs": [
[
"==",
"3.16.2"
]
]
}
],
"lcname": "hyprpy"
}