From: Jeremie Courreges-Anglas Subject: [wayland] seatd VT switching and device access for wlroots-based programs To: landry@openbsd.org, matthieu@openbsd.org Cc: ports@openbsd.org Date: Fri, 2 Jan 2026 17:07:06 +0100 The common/terminal.c changes are just a minor cleanup for consistency with the FreeBSD code, I suspect the current port would work just as well. The hopefully more useful part of the diff: using the rc script and the instructions in the README I get working VT switching both from the wayland/greetd prompt and from a "startxfce4 --wayland" session using labwc. If you're using greetd please test with the diff I sent earlier today. For some reason startcagebreak.sh appears to error out and go back to the greetd prompt. Hopefully the debugging instructions in the README will prove useful. I haven't tested other compositors. It would be tempting to add a _seatd group instead of telling users to add a local one, but well, it wouldn't remove the need for explicit configuration steps and we're short on uids/gids (tm). Thoughts? ok? Index: Makefile =================================================================== RCS file: /cvs/ports/sysutils/seatd/Makefile,v diff -u -p -r1.9 Makefile --- Makefile 19 Oct 2025 08:27:21 -0000 1.9 +++ Makefile 2 Jan 2026 13:39:31 -0000 @@ -1,6 +1,7 @@ COMMENT = minimal seat management daemon and universal library V = 0.9.1 +REVISION = 0 DISTNAME = seatd-$V CATEGORIES = sysutils Index: patches/patch-common_terminal_c =================================================================== RCS file: /cvs/ports/sysutils/seatd/patches/patch-common_terminal_c,v diff -u -p -r1.3 patch-common_terminal_c --- patches/patch-common_terminal_c 19 Oct 2025 08:27:21 -0000 1.3 +++ patches/patch-common_terminal_c 2 Jan 2026 13:52:16 -0000 @@ -16,14 +16,23 @@ Index: common/terminal.c #else #error Unsupported platform #endif -@@ -147,12 +153,25 @@ static int get_tty_path(int tty, char path[static TTYP +@@ -147,6 +153,23 @@ static int get_tty_path(int tty, char path[static TTYP } return 0; } +#elif defined(__OpenBSD__) +static int get_tty_path(int tty, char path[static TTYPATHLEN]) { + assert(tty >= 0); -+ if (snprintf(path, TTYPATHLEN, "/dev/ttyC%d", tty - 1) == -1) { ++ ++ // On OpenBSD ttyC0 maps to VT 1. ++ // We subtract one from the requested TTY number to compensate. If the ++ // user asked for TTY 0 (which is special on Linux), we just give them ++ // the first tty. ++ if (tty > 0) { ++ tty--; ++ } ++ ++ if (snprintf(path, TTYPATHLEN, "/dev/ttyC%d", tty) == -1) { + return -1; + } + return 0; @@ -31,18 +40,7 @@ Index: common/terminal.c #else #error Unsupported platform #endif - - int terminal_open(int vt) { - char path[TTYPATHLEN]; -+#ifdef __OpenBSD__ -+ if (vt == 0) { -+ snprintf(path, sizeof(path), "/dev/ttyC0"); -+ } else -+#endif - if (get_tty_path(vt, path) == -1) { - log_errorf("Could not generate tty path: %s", strerror(errno)); - return -1; -@@ -166,7 +185,7 @@ int terminal_open(int vt) { +@@ -166,7 +189,7 @@ int terminal_open(int vt) { } int terminal_current_vt(int fd) { @@ -51,7 +49,7 @@ Index: common/terminal.c struct vt_stat st; int res = ioctl(fd, VT_GETSTATE, &st); if (res == -1) { -@@ -201,7 +220,19 @@ int terminal_set_process_switching(int fd, bool enable +@@ -201,7 +224,19 @@ int terminal_set_process_switching(int fd, bool enable .acqsig = enable ? SIGUSR2 : 0, .frsig = FRSIG, }; @@ -72,7 +70,7 @@ Index: common/terminal.c if (ioctl(fd, VT_SETMODE, &mode) == -1) { log_errorf("Could not set VT mode to %s process switching: %s", enable ? "enable" : "disable", strerror(errno)); -@@ -241,12 +272,23 @@ int terminal_ack_acquire(int fd) { +@@ -241,12 +276,23 @@ int terminal_ack_acquire(int fd) { } int terminal_set_keyboard(int fd, bool enable) { @@ -96,7 +94,7 @@ Index: common/terminal.c #if defined(__FreeBSD__) struct termios tios; if (tcgetattr(fd, &tios) == -1) { -@@ -268,11 +310,22 @@ int terminal_set_keyboard(int fd, bool enable) { +@@ -268,11 +314,22 @@ int terminal_set_keyboard(int fd, bool enable) { } int terminal_set_graphics(int fd, bool enable) { Index: pkg/PLIST =================================================================== RCS file: /cvs/ports/sysutils/seatd/pkg/PLIST,v diff -u -p -r1.1.1.1 PLIST --- pkg/PLIST 13 Aug 2023 08:36:22 -0000 1.1.1.1 +++ pkg/PLIST 2 Jan 2026 15:40:37 -0000 @@ -1,3 +1,4 @@ +@rcscript ${RCDIR}/seatd @bin bin/seatd @bin bin/seatd-launch include/libseat.h @@ -5,3 +6,4 @@ include/libseat.h lib/pkgconfig/libseat.pc @man man/man1/seatd-launch.1 @man man/man1/seatd.1 +share/doc/pkg-readmes/${PKGSTEM} Index: pkg/README =================================================================== RCS file: pkg/README diff -N pkg/README --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ pkg/README 2 Jan 2026 15:43:25 -0000 @@ -0,0 +1,36 @@ ++------------------------------------------------------------------------------- +| Running ${PKGSTEM} on OpenBSD ++------------------------------------------------------------------------------- + +seatd provides VT switching and device access to clients +using libseat. It is particularly useful for wayland-based +applications. + +Setup +===== + +By default seatd's UNIX socket is only accessible by root. +Add a new group "seat" and add authorized to use seatd to that group: + + # group add seat + # user mod -G seat _greetd + # user mod -G seat jdoe + +Startup +======= + +Enable seatd so that it starts before services that need it. +Tell it to use the group we created above. + + # rcctl enable seatd + # rcctl order seatd + # rcctl set seatd flags -g seat + +Debugging +========= + +To debug or report issues, start seatd in the foreground with +a more verbose log level. + + # rcctl stop seatd + # seatd -g seat -l debug Index: pkg/seatd.rc =================================================================== RCS file: pkg/seatd.rc diff -N pkg/seatd.rc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ pkg/seatd.rc 2 Jan 2026 15:46:04 -0000 @@ -0,0 +1,8 @@ +#!/bin/ksh + +daemon="${TRUEPREFIX}/bin/seatd" + +. /etc/rc.d/rc.subr + +rc_bg=YES +rc_cmd $1 -- jca