Title: python-xlib fails to parse X server Visual/Depth info on Void Linux (Python 3.11/3.13) · Issue #282 · python-xlib/python-xlib · GitHub
Open Graph Title: python-xlib fails to parse X server Visual/Depth info on Void Linux (Python 3.11/3.13) · Issue #282 · python-xlib/python-xlib
X Title: python-xlib fails to parse X server Visual/Depth info on Void Linux (Python 3.11/3.13) · Issue #282 · python-xlib/python-xlib
Description: Bug Report: python-xlib fails to retrieve standard X server Visual/Depth information Description: I am encountering a persistent and unusual issue where python-xlib (both 0.33 and 0.29) on Void Linux (using Python 3.13 and Python 3.11) i...
Open Graph Description: Bug Report: python-xlib fails to retrieve standard X server Visual/Depth information Description: I am encountering a persistent and unusual issue where python-xlib (both 0.33 and 0.29) on Void Lin...
X Description: Bug Report: python-xlib fails to retrieve standard X server Visual/Depth information Description: I am encountering a persistent and unusual issue where python-xlib (both 0.33 and 0.29) on Void Lin...
Opengraph URL: https://github.com/python-xlib/python-xlib/issues/282
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"python-xlib fails to parse X server Visual/Depth info on Void Linux (Python 3.11/3.13)","articleBody":"### Bug Report: `python-xlib` fails to retrieve standard X server Visual/Depth information\n\n**Description:**\nI am encountering a persistent and unusual issue where `python-xlib` (both 0.33 and 0.29) on Void Linux (using Python 3.13 and Python 3.11) is unable to properly retrieve and expose X server visual and depth information, leading to `AttributeError` on expected properties and an inability to find the default visual in `screen.allowed_depths`.\n\nMy X server is functioning normally and reports standard visual information via `xdpyinfo`.\n\n**Environment:**\n* **Operating System:** Void Linux (x86_64)\n* **Python Version (tested):** Python 3.13.0) and Python 3.11.12_2\n* **`python-xlib` Version (tested):** 0.33 and 0.29\n* **X Server:** \"Xorg\" \n* **Desktop Environment/Window Manager:** Openbox\n\n**Steps to Reproduce:**\n1. Create a Python virtual environment (tested with both Python 3.13 and Python 3.11).\n2. Install `python-xlib==0.33` (then later tried 0.29) into the environment:\n `pip install python-xlib==0.33` (then `pip install python-xlib==0.29`)\n3. Ran Python script `test_xlib.py` to check basic `screen` properties.\n4. Ran Python script `center_dot.py` which attempts to find and use the default visual.\n\n**Expected Behavior:**\nThe `python-xlib` library should successfully access properties like `screen.default_visual`, `screen.default_depth`, `root.get_geometry().visual`, and `visual_obj.id` within `screen.allowed_depths`. It should be able to identify and use the default visual (0x20 / 32) and depth (24) reported by `xdpyinfo`.\n\n**Actual Behavior / Error Messages:**\n\n\n---\n**1. Output from `test_xlib.py` (with python-xlib 0.33):**\n\nSuccessfully connected to X server.\nScreen width: 1920\nScreen height: 1080\nRoot visual ID (screen.root_visual): 32\nRoot depth (screen.root_depth): 24\nAttributeError trying to get screen properties: get_visual_from_id\nThis indicates a deep issue with python-xlib's interaction with your X server.\nDisconnected from X server.\n\n**2. Output from `center_dot.py` (after attempts with `getattr` workaround, python-xlib 0.33, Python 3.13):**\nCRITICAL: Could not find a matching Visual object for ID 32 and depth 24. Exiting.\n\n*(Note: This occurred after the `AttributeError: id` was bypassed by `getattr`.)*\n\n**3. Output from `center_dot.py` (with python-xlib 0.29, Python 3.11):**\n\nWarning: 'screen.default_visual' or 'screen.default_depth' not found directly. Falling back to root geometry.\nTraceback (most recent call last):\nFile \"/home/XXX/pyxdg_env_py311/lib/python3.11/site-packages/Xlib/protocol/rq.py\", line 1294, in getattr\nreturn self._data[attr]\n~~~~~~~~~~^^^^^^\nKeyError: 'default_visual'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\nFile \"/home/XXXX/python_scripts/center_dot.py\", line 34, in create_centered_dot_overlay\nselected_visual = screen.default_visual\n^^^^^^^^^^^^^^^^^^^^^\nFile \"/home/XXXX/pyxdg_env_py311/lib/python3.11/site-packages/Xlib/protocol/rq.py\", line 1298, in getattr\nraise AttributeError(attr)\nAttributeError: default_visual\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\nFile \"/home/XXXX/pyxdg_env_py311/lib/python3.11/site-packages/Xlib/protocol/rq.py\", line 1294, in getattr\nreturn self._data[attr]\n~~~~~~~~~~^^^^^^\nKeyError: 'visual'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\nFile \"/home/XXXX/python_scripts/center_dot.py\", line 144, in \u0026lt;module\u003e\ncreate_centered_dot_overlay()\nFile \"/home/XXXX/python_scripts/center_dot.py\", line 41, in create_centered_dot_overlay\nif isinstance(geometry.visual, int):\n^^^^^^^^^^^^^^^\nFile \"/home/XXXX/pyxdg_env_py311/lib/python3.11/site-packages/Xlib/protocol/rq.py\", line 1298, in getattr\nraise AttributeError(attr)\nAttributeError: visual\n\n**4. Output from `xdpyinfo | grep -E \"visual|depths\"` (showing correct X server data):**\n\ndepths (7): 24, 1, 4, 8, 15, 16, 32\nnumber of visuals: 156\ndefault visual id: 0x20\nvisual:\nvisual id: 0x20\n\n**5. Python Script `test_xlib.py` (as provided earlier):**\n\n```python\n# ~/python_scripts/test_xlib.py\n#!/usr/bin/env python3\nimport Xlib.display\nimport Xlib.X\n\ntry:\n display = Xlib.display.Display()\n screen = display.screen()\n root = screen.root\n\n print(\"Successfully connected to X server.\")\n print(f\"Screen width: {root.get_geometry().width}\")\n print(f\"Screen height: {root.get_geometry().height}\")\n\n try:\n print(f\"Root visual ID (screen.root_visual): {screen.root_visual}\")\n print(f\"Root depth (screen.root_depth): {screen.root_depth}\")\n\n # This is the line that failed last:\n test_visual_object = screen.get_visual_from_id(screen.root_visual)\n print(f\"Got visual object from ID. Its ID is: {test_visual_object.id}\")\n\n except AttributeError as e:\n print(f\"AttributeError trying to get screen properties: {e}\")\n print(\"This indicates a deep issue with python-xlib's interaction with your X server.\")\n except Exception as e:\n print(f\"An unexpected error occurred while getting screen properties: {e}\")\n\n display.close()\n print(\"Disconnected from X server.\")\n\nexcept Xlib.error.DisplayNameError:\n print(\"ERROR: Cannot open display. Is X server running and DISPLAY environment variable set?\")\nexcept Exception as e:\n print(f\"An unexpected error occurred during Xlib initialization: {e}\")\n\n# ~/python_scripts/center_dot.py\n#!/usr/bin/env python3\nimport Xlib.display\nimport Xlib.X\nimport Xlib.protocol.event\nfrom Xlib.ext import xfixes\nimport time\n\ndef create_centered_dot_overlay():\n display = Xlib.display.Display()\n screen = display.screen()\n root = screen.root\n\n screen_width = root.get_geometry().width\n screen_height = root.get_geometry().height\n center_x = screen_width // 2\n center_y = screen_height // 2\n\n TARGET_VISUAL_ID_DEC = 32\n TARGET_DEPTH = 24\n\n selected_visual = None\n found_depth = None\n\n print(f\"Searching for visual ID {TARGET_VISUAL_ID_DEC} with depth {TARGET_DEPTH}...\")\n for depth_info in screen.allowed_depths:\n print(f\" Checking depth: {depth_info.depth}\")\n if depth_info.depth == TARGET_DEPTH:\n for visual_obj in depth_info.visuals:\n visual_id_val = getattr(visual_obj, 'id', None)\n if visual_id_val is not None and visual_id_val == TARGET_VISUAL_ID_DEC:\n selected_visual = visual_obj\n found_depth = depth_info.depth\n print(f\" --\u003e Found matching visual: ID {selected_visual.id}, Depth {found_depth}\")\n break\n if selected_visual:\n break\n\n if selected_visual is None:\n print(f\"CRITICAL: Could not find a matching Visual object for ID {TARGET_VISUAL_ID_DEC} and depth {TARGET_DEPTH} within screen.allowed_depths. Exiting.\")\n print(\"This indicates a severe incompatibility or issue with your python-xlib installation or X server configuration.\")\n display.close()\n exit(1)\n\n print(f\"Using visual ID: {selected_visual.id} with depth: {found_depth}\")\n print(\"Transparency might not work without a compositing manager (Picom/Compton) and a suitable visual.\")\n\n window = root.create_window(\n 0, 0, screen_width, screen_height, 0,\n found_depth,\n Xlib.X.InputOutput,\n selected_visual,\n Xlib.X.CWBackPixel | Xlib.X.CWEventMask | Xlib.X.CWOverrideRedirect | Xlib.X.CWColormap,\n {\n 'background_pixel': 0,\n 'event_mask': Xlib.X.ExposureMask,\n 'override_redirect': True,\n 'colormap': display.create_colormap(root, selected_visual, Xlib.X.AllocNone)\n }\n )\n\n NET_WM_STATE = display.intern_atom('_NET_WM_STATE')\n _NET_WM_STATE_ABOVE = display.intern_atom('_NET_WM_STATE_ABOVE')\n window.change_property(\n Xlib.X.ChangePropertyModeReplace,\n NET_WM_STATE,\n Xlib.display.None_,\n 32,\n [_NET_WM_STATE_ABOVE]\n )\n event = Xlib.protocol.event.ClientMessage(\n window=window,\n client_type=NET_WM_STATE,\n data=(32, (_NET_WM_STATE_ABOVE, 1, 0, 0, 0))\n )\n root.send_event(event, Xlib.X.SubstructureNotifyMask | Xlib.X.SubstructureRedirectMask)\n\n empty_region = xfixes.create_region(display)\n xfixes.set_window_shape_region(display, window.id, Xlib.X.ShapeInput, 0, 0, empty_region)\n empty_region.free()\n\n window.map_window()\n display.sync()\n\n dot_color = screen.black_pixel\n gc = window.create_gc(\n foreground=dot_color,\n function=Xlib.X.GXcopy\n )\n\n try:\n while True:\n event = display.next_event()\n if event.type == Xlib.X.Expose:\n dot_size = 3\n window.fill_arc(gc, center_x - dot_size, center_y - dot_size,\n dot_size * 2, dot_size * 2, 0, 360 * 64)\n display.flush()\n time.sleep(0.01)\n except KeyboardInterrupt:\n print(\"\\nExiting dot overlay.\")\n finally:\n gc.free()\n window.destroy()\n display.close()\n\nif __name__ == \"__main__\":\n create_centered_dot_overlay()\n\n\nxdpyinfo shows correct X server data.\nattempted different python-xlib versions and Python interpreter versions without success.\nissue isolated to python-xlib's internal handling of X server responses.\n","author":{"url":"https://github.com/Schaekker","@type":"Person","name":"Schaekker"},"datePublished":"2025-06-02T16:17:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/282/python-xlib/issues/282"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8227b7d7-b52c-bde7-7b18-ad8af48566f5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 845C:DAAA2:727C9:A23A1:696F9507 |
| html-safe-nonce | 9fd1a0d31427ba60d26925aa7529fc5e25040b5894fa3f86fbd46ce2eb486f19 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDVDOkRBQUEyOjcyN0M5OkEyM0ExOjY5NkY5NTA3IiwidmlzaXRvcl9pZCI6IjIzMjg5Mjg3MzA3ODE1NTM5MjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4d162c297b55f7afc861fb7ab626294860ff2173b383e2914898cd8b0200389a |
| hovercard-subject-tag | issue:3110810465 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-xlib/python-xlib/282/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8d1650781236e364e3e2f2dbaeaaa63b2707342c23ff6c9454b4784f2972a0a4/python-xlib/python-xlib/issues/282 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8d1650781236e364e3e2f2dbaeaaa63b2707342c23ff6c9454b4784f2972a0a4/python-xlib/python-xlib/issues/282 |
| og:image:alt | Bug Report: python-xlib fails to retrieve standard X server Visual/Depth information Description: I am encountering a persistent and unusual issue where python-xlib (both 0.33 and 0.29) on Void Lin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Schaekker |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0ca8d8c65612640b9a1a588b3eed68222ca723ed2d028b18fe81b28936d535eb |
| turbo-cache-control | no-preview |
| go-import | github.com/python-xlib/python-xlib git https://github.com/python-xlib/python-xlib.git |
| octolytics-dimension-user_id | 16151530 |
| octolytics-dimension-user_login | python-xlib |
| octolytics-dimension-repository_id | 47391866 |
| octolytics-dimension-repository_nwo | python-xlib/python-xlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 47391866 |
| octolytics-dimension-repository_network_root_nwo | python-xlib/python-xlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 95f60616ce2765d1114fe6da4af405a58c6d26d2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width