{"id":17941814,"url":"https://github.com/nikolai2038/display-autoresize","last_synced_at":"2026-05-01T09:31:37.662Z","repository":{"id":259763239,"uuid":"871773657","full_name":"Nikolai2038/display-autoresize","owner":"Nikolai2038","description":"Script to autoresize display in SPICE session (X11 and Wayland Sway)","archived":false,"fork":false,"pushed_at":"2025-01-13T20:39:10.000Z","size":6333,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T13:20:02.299Z","etag":null,"topics":["bash","display-autoresize","drm-info","i3","jq","libvirt","screen","spice","spice-vdagent","sway","wayland","wlr-randr","x11","xfce","xrandr"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nikolai2038.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-12T22:29:45.000Z","updated_at":"2025-01-13T20:38:11.000Z","dependencies_parsed_at":"2025-01-13T21:22:49.230Z","dependency_job_id":"dbc85c11-470e-4f6d-91e9-261d0babbe9a","html_url":"https://github.com/Nikolai2038/display-autoresize","commit_stats":null,"previous_names":["nikolai2038/display-autoresize"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fdisplay-autoresize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fdisplay-autoresize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fdisplay-autoresize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nikolai2038%2Fdisplay-autoresize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nikolai2038","download_url":"https://codeload.github.com/Nikolai2038/display-autoresize/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247006667,"owners_count":20868033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","display-autoresize","drm-info","i3","jq","libvirt","screen","spice","spice-vdagent","sway","wayland","wlr-randr","x11","xfce","xrandr"],"created_at":"2024-10-29T02:04:18.597Z","updated_at":"2026-05-01T09:31:37.618Z","avatar_url":"https://github.com/Nikolai2038.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# display-autoresize\n\n**EN** | [RU](README_RU.md)\n\n## 1. Description\n\nScript to autoresize display in SPICE session. Tested on Arch Linux with:\n\n- X11: `i3` windows manager;\n- Wayland: `sddm` login manager, `sway` wayland compositor.\n\nPreview:\n\n![preview.gif](preview.gif)\n\n## 2. Requirements\n\n### 2.1. Guest\n\n1. Install required packages:\n\n    - Arch-based:\n\n        ```bash\n        sudo pacman --sync --refresh --needed bash xorg-xrandr screen jq spice-vdagent xf86-video-qxl\n        ```\n\n        - `bash` - for script execution;\n        - `xorg-xrandr` - for `xrandr` command to get and modify display outputs;\n        - `screen` - to run script for sway in background;\n        - `jq` - to parse `swaymsg` output;\n        - `spice-vdagent` and `xf86-video-qxl` - SPICE guest tools.\n\n2. Install `drm_info`:\n\n    - Arch-based:\n\n        ```bash\n        yay --sync --refresh --needed --sudoloop drm_info\n        ```\n\n3. Download script `display-autoresize` from this repository and make it executable:\n\n    ```bash\n    sudo wget -O /usr/local/bin/display-autoresize https://raw.githubusercontent.com/Nikolai2038/display-autoresize/refs/heads/main/display-autoresize \u0026\u0026 \\\n    sudo chmod +x /usr/local/bin/display-autoresize\n    ```\n\n   - You can put script not in `/usr/local/bin/display-autoresize`, but make sure to change path to it in udev rule too (see below).\n\n4. Create udev rule:\n\n    ```bash\n    echo 'ACTION==\"change\", KERNEL==\"card[0-9]*\", SUBSYSTEM==\"drm\", RUN+=\"/usr/local/bin/display-autoresize\"' | sudo tee /etc/udev/rules.d/50-display-autoresize.rules \u0026\u0026 \\\n    sudo udevadm control --reload-rules\n    ```\n\n5. Make sure `spice-vdagentd` is loaded and running fine.\n\n#### 2.1.1. [UNSTABLE] Login Manager (SDDM)\n\nAdditionally, if you want this script to work for login manager you are using (SDDM for example) - make sure to start login manager from unprivileged user.\nAs I tested with SDDM, if it is running from root, `udev` events does not occur so script to autoresize is not called.\nTo start SDDM as unprivileged user:\n\n```bash\nsudo mkdir --parents /etc/sddm.conf.d \u0026\u0026 \\\necho '[General]\nDisplayServer=x11-user' | sudo tee /etc/sddm.conf.d/set_compositor.conf \u0026\u0026 \\\necho 'allowed_users = anybody\nneeds_root_rights = no' | sudo tee --append /etc/X11/Xwrapper.config \u0026\u0026 \\\nsudo systemctl restart sddm.service\n```\n\nFor more info, check:\n\n```bash\nman sddm.conf\nman Xorg.wrap\n```\n\nUpdate 2025-01-13:\n\n- I tried `x11-user` and `wayland` for `DisplayServer` setting for some time, and found out, that they are a lot more unstable, than the default `x11` setting. Specifically, `x11-user` will cause user session (after you logged in) to crash after some time. As for `wayland` - it has freeze problems when connected via `aSPICE` Android app. I don't test all this properly, but will stick to default `x11` for now.\n\n### 2.2. Host\n\nJust make sure that auto-resize is enabled when you are connecting via `virt-viewer`/`spicy`.\n\n## 3. Debugging\n\n- Watch udev events on resize with `udevadm monitor`;\n- Watch `dmesg -w` (may not be super useful);\n- Watch logs with `tail -f /var/log/display-autoresize.log`.\n\n## 4. Credits\n\n- \"Forked\" from [gist](https://gist.github.com/IngoMeyer441/84cf1e40fa756a9c3e6c8d9e38ee9b6f) but with `XAUTHORITY` and Sway (Wayland) support;\n- Credit for [finding sessions as root](https://unix.stackexchange.com/questions/117083/how-to-get-the-list-of-all-active-x-sessions-and-owners-of-them);\n- Credit for [resizing via udev](https://superuser.com/questions/1183834/no-auto-resize-with-spice-and-virt-manager);\n- Credit for [`drm_info` solution](https://todo.sr.ht/~emersion/wlr-randr/15) to get current window resolution in Wayland.\n\n## 5. Contribution\n\nYou can help me with:\n\n- Testing in other distributions (Debian, Fedora, etc.) and update instructions for them;\n- Testing on other Window Managers and Wayland compositors;\n- Maybe optimizing code and finding more elegant and fast solutions for parsing;\n- Translate `README.md` to other languages.\n\nFeel free to contribute via [pull requests](https://github.com/Nikolai2038/display-autoresize/pulls) or [issues](https://github.com/Nikolai2038/display-autoresize/issues)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolai2038%2Fdisplay-autoresize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikolai2038%2Fdisplay-autoresize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolai2038%2Fdisplay-autoresize/lists"}