{ "info": { "author": "Giacomo Comitti", "author_email": "dev@gcomit.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# i3pie\n\ni3wm ipc library for python.\n\n## Installation\n\n```\npip install i3pie\n```\n\n## Usage\n\n```python\n>>> import i3pie\n>>> with i3pie.Connection() as i3:\n... tree = i3.get_tree()\n... tree._pprint()\n...\ntype='root' name='root'\n\u251c\u2500 type='output' name='HDMI-A-0'\n\u2502 \u251c\u2500 type='dockarea' name='bottomdock'\n\u2502 \u251c\u2500 type='con' name='content'\n\u2502 \u2502 \u251c\u2500 type='workspace' name='2'\n\u2502 \u2502 \u2502 \u2514\u2500 type='con'\n\u2502 \u2502 \u2502 \u2514\u2500 window=50331658 type='con' class='Nemo'\n\u2502 \u2502 \u2514\u2500 type='workspace' name='1'\n\u2502 \u2502 \u2514\u2500 type='con'\n\u2502 \u2502 \u251c\u2500 window=37748745 type='con' class='URxvt'\n\u2502 \u2502 \u2514\u2500 window=25165827 type='con' class='firefox'\n\u2502 \u2514\u2500 type='dockarea' name='topdock'\n\u2502 \u2514\u2500 window=23068674 type='con' class='Polybar'\n\u2514\u2500 type='output' name='__i3'\n \u2514\u2500 type='con' name='content'\n \u2514\u2500 type='workspace' name='__i3_scratch'\n \u2514\u2500 type='floating_con'\n \u2514\u2500 window=44040194 type='con' class='mpv'\n```\n\n### Sending commands\n```python\n>>> import i3pie\n>>> i3 = i3pie.Connection()\n>>> tree = i3.get_tree()\n\n>>> focused = tree.focused_window()\n>>> focused.command('move to workspace 2')\nCommandReply(success=True)\n\n>>> windows = list(tree.current_workspace().windows())\n>>> i3.command('kill', windows)\nCommandReply(success=True)\n```\n\n### Working with the tree\n```python\n>>> import i3pie\n>>> i3 = i3pie.Connection()\n>>> tree = i3.get_tree()\n\n>>> focused = tree.focused_window()\n>>> print(focused)\n\n\n>>> focused.workspace()\nContainer(type='workspace', name='1')\n\n>>> focused.output()\nContainer(type='output', name='HDMI-A-0')\n\n>>> tree = focused.root()\n>>> print(tree)\n\n\n>>> list(tree.workspaces())\n[Container(type='workspace', name='1'), Container(type='workspace', name='2')]\n\n>>> list(tree.workspaces(scratchpad=True))\n[Container(type='workspace', name='__i3_scratch'), Container(type='workspace', name='1'), Container(type='workspace', name='2')]\n\n>>> scratchpad = tree.scratchpad()\n>>> print(scratchpad)\n\n\n>>> list(scratchpad.windows())\n[Container(window=44040194, type='con', class='mpv')]\n\n>>> print(list(scratchpad.windows()))\n[Container(window=44040194, type='con', class='mpv')]\n\n>>> list(tree.outputs())\n[Container(type='output', name='HDMI-A-0')]\n\n>>> tree.find_window(fn=lambda con: 'Firefox' in con.name)\nContainer(window=25165827, type='con', class='firefox')\n\n>>> tree.find_workspace(fn=lambda w: w.num == 2)\nContainer(type='workspace', name='2')\n\n>>> for win in tree.windows():\n... if win.window_class == 'URxvt':\n... print(win)\n...\n\n\n>>> list(tree.filter(fn=lambda con: con.is_window and con.window_class == 'mpv'))\n[]\n\n>>> list(tree.filter(fn=lambda con: con.is_window and con.window_class == 'mpv', i3=True))\n[Container(window=44040194, type='con', class='mpv')]\n```\n\n### Getting workspaces and outputs\n```python\n>>> import i3pie\n>>> i3 = i3pie.Connection()\n>>> for workspace in i3.get_workspaces():\n... print(workspace.name)\n...\n1\n2\n\n>>> for output in i3.get_outputs():\n... print(output.name)\n...\nHDMI-A-0\nxroot-0\n```\n\n### Getting marks and binding modes\n```python\n>>> import i3pie\n>>> i3 = i3pie.Connection()\n\n>>> print(i3.get_marks())\n\n\n>>> print(i3.get_binding_modes())\n\n```\n\n### Subscribe to events\n```python\nfrom i3pie import Event, Connection\n\ndef callback(self, conn, event, data):\n window = data['container']\n if data['change'] != 'new' or not window:\n\t return\n window.command('floating enable')\n\nwith Connection() as i3:\n i3.subscribe(Event.WINDOW, callback)\n i3.listen()\n```\n\n### Examples\n\n#### Cycling workspaces\n```python\nimport i3pie, argparse\n\ndef main(i3):\n\n parser = argparse.ArgumentParser(description=\"Cycle i3 workspaces\")\n group = parser.add_mutually_exclusive_group(required=True)\n group.add_argument(\"-next\", action=\"store_true\", help=\"focus next workspace\")\n group.add_argument(\"-prev\", action=\"store_true\", help=\"focus previous workspace\")\n args = parser.parse_args()\n\n tree = i3.get_tree()\n workspaces = list(tree.workspaces())\n current = tree.current_workspace()\n\n idx = workspaces.index(current)\n direction = 1 if args.next else -1\n target = workspaces[(idx + direction) % len(workspaces)]\n i3.command(f'workspace \"{target.name}\"')\n\nif __name__ == \"__main__\":\n with i3pie.Connection() as i3:\n main(i3)\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gcmt/i3pie", "keywords": "i3 i3wm", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "i3pie", "package_url": "https://pypi.org/project/i3pie/", "platform": "", "project_url": "https://pypi.org/project/i3pie/", "project_urls": { "Homepage": "https://github.com/gcmt/i3pie" }, "release_url": "https://pypi.org/project/i3pie/1.0/", "requires_dist": null, "requires_python": ">=3.6", "summary": "IPC library for i3wm", "version": "1.0" }, "last_serial": 5736609, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "2e965c931ee0bf482771c1a1e69d13ca", "sha256": "107cd2bd8dbcde91964b5a701055748f53eaa5207e35fd7b95141031b7f66764" }, "downloads": -1, "filename": "i3pie-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "2e965c931ee0bf482771c1a1e69d13ca", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 16595, "upload_time": "2019-08-27T13:02:08", "url": "https://files.pythonhosted.org/packages/da/6a/73a9c3ca2ef8ce1e17d0b6346202a20b233d948e33183518f48a2d0cb57c/i3pie-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1a532e3e97fc22d3f16ac9a5db7654f7", "sha256": "d248df5d22ee4b06cd24ccd6088575bebd0a62be89b9bbabe1d49834ca7ef270" }, "downloads": -1, "filename": "i3pie-1.0.tar.gz", "has_sig": false, "md5_digest": "1a532e3e97fc22d3f16ac9a5db7654f7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15901, "upload_time": "2019-08-27T13:02:10", "url": "https://files.pythonhosted.org/packages/30/8c/65ffa589696e4f5c05fd202d513ce0445a4c05452f08fe80b482a4db2751/i3pie-1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2e965c931ee0bf482771c1a1e69d13ca", "sha256": "107cd2bd8dbcde91964b5a701055748f53eaa5207e35fd7b95141031b7f66764" }, "downloads": -1, "filename": "i3pie-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "2e965c931ee0bf482771c1a1e69d13ca", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6", "size": 16595, "upload_time": "2019-08-27T13:02:08", "url": "https://files.pythonhosted.org/packages/da/6a/73a9c3ca2ef8ce1e17d0b6346202a20b233d948e33183518f48a2d0cb57c/i3pie-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1a532e3e97fc22d3f16ac9a5db7654f7", "sha256": "d248df5d22ee4b06cd24ccd6088575bebd0a62be89b9bbabe1d49834ca7ef270" }, "downloads": -1, "filename": "i3pie-1.0.tar.gz", "has_sig": false, "md5_digest": "1a532e3e97fc22d3f16ac9a5db7654f7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15901, "upload_time": "2019-08-27T13:02:10", "url": "https://files.pythonhosted.org/packages/30/8c/65ffa589696e4f5c05fd202d513ce0445a4c05452f08fe80b482a4db2751/i3pie-1.0.tar.gz" } ] }