From: Demi Marie Obenour <demiobenour@gmail.com>
To: Spectrum OS Development <devel@spectrum-os.org>
Cc: Alyssa Ross <hi@alyssa.is>, Demi Marie Obenour <demiobenour@gmail.com>
Subject: [PATCH] host/rootfs: Automatically select card node
Date: Sun, 24 May 2026 16:51:55 -0400 [thread overview]
Message-ID: <20260524-weston-card-fix-v1-1-9c6dad59c245@gmail.com> (raw)
This allows Weston to launch even if there if /dev/dri/card0 does not
exist.
This requires a shell script for string processing. It could be written
in Rust, but that's not worth it for a temporary workaround.
It also prevents waiting for the card to be ready. Instead, let s6
restart Weston over and over until Weston finally runs.
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
This makes Spectrum work on my AMD system.
---
host/rootfs/file-list.mk | 1 +
host/rootfs/image/etc/s6-rc/weston/run | 6 +++---
host/rootfs/image/usr/bin/run-weston | 32 ++++++++++++++++++++++++++++++++
3 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/host/rootfs/file-list.mk b/host/rootfs/file-list.mk
index 3899d620717fc97f42e669e5313c4100dcf5b1cd..0ece8e08a0e2d367fe124e90896355aa98a58cb8 100644
--- a/host/rootfs/file-list.mk
+++ b/host/rootfs/file-list.mk
@@ -62,6 +62,7 @@ FILES = \
image/usr/bin/run-appimage \
image/usr/bin/run-flatpak \
image/usr/bin/run-vmm \
+ image/usr/bin/run-weston \
image/usr/bin/spectrum-update \
image/usr/bin/vm-console \
image/usr/bin/vm-import \
diff --git a/host/rootfs/image/etc/s6-rc/weston/run b/host/rootfs/image/etc/s6-rc/weston/run
index fd59586c719391deb546c29578341e16a61ed4ce..6c0aac4a2326b5d56b9c09f82589dfbcc78eaabd 100644
--- a/host/rootfs/image/etc/s6-rc/weston/run
+++ b/host/rootfs/image/etc/s6-rc/weston/run
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2021, 2025 Alyssa Ross <hi@alyssa.is>
-importas -Siu WAYLAND_DISPLAY
+importas -Si WAYLAND_DISPLAY
piperw 4 3
background {
@@ -40,7 +40,6 @@ redirfd -r 0 /dev/tty1
importas -i home HOME
cd $home
-if { udevadm wait /dev/dri/card0 }
s6-setuidgid wayland
bwrap
# no --unshare-net, breaks udev hotplug
@@ -88,4 +87,5 @@ bwrap
--bind /run/user/0 /run/user/0
--bind /run/wayland /run/wayland
--
-weston -S $WAYLAND_DISPLAY
+ elglob -w0 CARD "/dev/dri/card[0-9]*"
+ /usr/bin/run-weston $CARD
diff --git a/host/rootfs/image/usr/bin/run-weston b/host/rootfs/image/usr/bin/run-weston
new file mode 100755
index 0000000000000000000000000000000000000000..6a14f905d2e9e5533d00aac1ee7f920ebf55fac3
--- /dev/null
+++ b/host/rootfs/image/usr/bin/run-weston
@@ -0,0 +1,32 @@
+#!/usr/bin/sh --
+# SPDX-License-Identifier: EUPL-1.2+
+# SPDX-FileCopyrightText: 2026 Demi Marie Obenour <demiobenour@gmail.com>
+set -euf
+case ${1-} in
+/dev/dri/card[0-9]*)
+ first_dev=${1#/dev/dri/} extra_cards=
+ shift
+ ;;
+*)
+ echo 'No card nodes found, cannot run Weston' >&2
+ exit 1
+ ;;
+esac
+for i; do
+ case $i in
+ *,*) continue ;;
+ /dev/dri/card[0-9]*) : ;;
+ *)
+ echo 'Bad name from execline script' >&2
+ exit 1
+ ;;
+ esac
+ card_name=${i#/dev/dri/}
+ case $card_name in */*) continue ;; esac
+ if [ -z "$extra_cards" ]; then
+ extra_cards=--additional-devices=$card_name
+ else
+ extra_cards=$extra_cards,$card_name
+ fi
+done
+exec weston --backend=drm "--drm-device=$first_dev" $extra_cards -S "$WAYLAND_DISPLAY"
---
base-commit: 4827f7591e945f331a945fb53a9fd4e8ebfdbc12
change-id: 20260523-weston-card-fix-725c98d5245f
--
Sincerely,
Demi Marie Obenour (she/her/hers)
next reply other threads:[~2026-05-24 20:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-24 20:51 Demi Marie Obenour [this message]
2026-05-25 17:08 ` [PATCH] host/rootfs: Automatically select card node Alyssa Ross
2026-05-26 7:31 ` [PATCH v2] host/rootfs: Don't wait for /dev/dri/card0 Demi Marie Obenour
2026-05-26 14:15 ` Alyssa Ross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260524-weston-card-fix-v1-1-9c6dad59c245@gmail.com \
--to=demiobenour@gmail.com \
--cc=devel@spectrum-os.org \
--cc=hi@alyssa.is \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).