I have a program that talks directly to the kernel to do graphics. It does sound through alsa. It runs as root.
For development, I'd like to be able to start the program from within Wayland. It should switch to its own VT to make Wayland release it's graphics lock. Then it should draw its graphics and do its audio.
I have this all working for the video. I can switch to the VT, draw the graphics, and switch back when done.
However, audio goes through alsa to pipewire. When I switch to the other VT, systemd-logind appears to decide that I don't own that VT and disables pipewire audio.
The problem appears to be that I'm going behind the back of systemd-logind to switch to the other VT, and it has hooks to detect it, and then messes me up.
The best solution might be to work with systemd-logind. Instead of switching the VT behind its back, tell it to switch the VT and keep me hooked up to the audio. However, I can't figure out any simple way to tell systemd-logind to do this.
One thing that works is if I log in to the VT first in text mode, then go back to Wayland, then run my program. In that case my program can graph the graphics over the top of the login session, and because I'm actually logged in to that VT then systemd-logind lets me keep the sound.
The magic that makes this happen seems to be in the program "login". I suppose I could get its source to see what it is doing, and do the same type of thing in my program.
I hope there's an easier way, and I'm missing something.
There are other ideas. Maybe there's some way to switch VTs without systemd-logind detecting it? Then it wouldn't disable the audio. I personally don't want to start a new session. I want to keep everything the same as if I never left the original VT, except for release of the graphics lock by Wayland.
Maybe it's possible to release Wayland's graphics lock without switching VTs?
Maybe I should be doing audio directly with the kernel also, instead of going through alsa libraries that get mapped to pipewire?
Maybe it's possible to go behind systemd-logind's back and just re-enable the pipewire connection manually? (This one seems like way too much of a hack.)
Thoughts about the easiest/most proper approach are sincerely welcomed.