From f123f0ba05bd09c668933f3930c8a37456b47255 Mon Sep 17 00:00:00 2001 From: VallierDev <24893073+VallierDev@users.noreply.github.com> Date: Thu, 15 Oct 2026 10:48:45 +0800 Subject: [PATCH] Document Arch and Omarchy setup and exercise native desktop input and clipboard --- AGENTS.md | 23 +++++++++++++++++++++++ README.en.md | 23 +++++++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ src/clipboard_probe.rs | 37 +++++++++++++++++++++---------------- src/main.rs | 26 +++++++++++++++++++++++++- 5 files changed, 115 insertions(+), 17 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a531115..fe54078 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -252,3 +252,26 @@ Changing the switch restarts only the scoped audio encoder; normal non-muted cap The supervisor imports DISPLAY and XAUTHORITY into the linger user bus, waits for authenticated X11 readiness, and keeps its cleanup trap alive. The sample drop-in uses `%t/uu-virtual-99.Xauthority`. Use a dedicated headless account. See the [setup and official Mac acceptance checklist](contrib/virtual-desktop/ACCEPTANCE.md). + +### Arch Linux / Omarchy + +```sh +sudo pacman -S --needed base-devel rust pkgconf clang ffmpeg libx11 libxext libxtst libxfixes gtk3 \ + wayland libxkbcommon wl-clipboard libpipewire glib2 libpulse +cargo test --locked --features wayland +cargo build --release --features wayland +``` + +Omarchy uses Hyprland: run in its user session, select `UU_DESKTOP_BACKEND=wayland`, +and retain `WAYLAND_DISPLAY` / `XDG_RUNTIME_DIR`. This requires wlr-screencopy and the +virtual input protocols supported by Hyprland; other compositors may need `--features wayland,portal`. +For uinput, load `uinput` and apply the uaccess rule above; seat ACLs require an active login. +For unattended accounts, explicitly restrict `/dev/uinput` access to a dedicated group. +This permission can inject into the whole seat, including lock/greeter screens. +`UU_INPUT_BACKEND=uinput` requests kernel devices; verify startup actually reports uinput. +Optional VAAPI: `intel-media-driver` (modern Intel) or `libva-mesa-driver` (AMD), `libva-utils` +for `vainfo`. Optional KMS: `libdrm`. Virtual Xfce: `xorg-server-xvfb xorg-xauth xorg-xdpyinfo +xfce4-session xfce4-panel xfdesktop xfwm4 gnome-terminal`. +Rolling Arch FFmpeg may be newer than supported `inproc-av` (FFmpeg 6.x); use the default process +pipeline or build against a separate FFmpeg 6 prefix. Do not downgrade the system FFmpeg. +User-bus headless setup and the official Mac checklist: [virtual desktop acceptance](contrib/virtual-desktop/ACCEPTANCE.md). diff --git a/README.en.md b/README.en.md index dcb3dea..445deae 100644 --- a/README.en.md +++ b/README.en.md @@ -290,3 +290,26 @@ Changing the switch restarts only the scoped audio encoder; normal non-muted cap The supervisor imports DISPLAY and XAUTHORITY into the linger user bus, waits for authenticated X11 readiness, and keeps its cleanup trap alive. The sample drop-in uses `%t/uu-virtual-99.Xauthority`. Use a dedicated headless account. See the [setup and official Mac acceptance checklist](contrib/virtual-desktop/ACCEPTANCE.md). + +### Arch Linux / Omarchy + +```sh +sudo pacman -S --needed base-devel rust pkgconf clang ffmpeg libx11 libxext libxtst libxfixes gtk3 \ + wayland libxkbcommon wl-clipboard libpipewire glib2 libpulse +cargo test --locked --features wayland +cargo build --release --features wayland +``` + +Omarchy uses Hyprland: run in its user session, select `UU_DESKTOP_BACKEND=wayland`, +and retain `WAYLAND_DISPLAY` / `XDG_RUNTIME_DIR`. This requires wlr-screencopy and the +virtual input protocols supported by Hyprland; other compositors may need `--features wayland,portal`. +For uinput, load `uinput` and apply the uaccess rule above; seat ACLs require an active login. +For unattended accounts, explicitly restrict `/dev/uinput` access to a dedicated group. +This permission can inject into the whole seat, including lock/greeter screens. +`UU_INPUT_BACKEND=uinput` requests kernel devices; verify startup actually reports uinput. +Optional VAAPI: `intel-media-driver` (modern Intel) or `libva-mesa-driver` (AMD), `libva-utils` +for `vainfo`. Optional KMS: `libdrm`. Virtual Xfce: `xorg-server-xvfb xorg-xauth xorg-xdpyinfo +xfce4-session xfce4-panel xfdesktop xfwm4 gnome-terminal`. +Rolling Arch FFmpeg may be newer than supported `inproc-av` (FFmpeg 6.x); use the default process +pipeline or build against a separate FFmpeg 6 prefix. Do not downgrade the system FFmpeg. +User-bus headless setup and the official Mac checklist: [virtual desktop acceptance](contrib/virtual-desktop/ACCEPTANCE.md). diff --git a/README.md b/README.md index 5599bde..8263a6b 100644 --- a/README.md +++ b/README.md @@ -272,3 +272,26 @@ Changing the switch restarts only the scoped audio encoder; normal non-muted cap The supervisor imports DISPLAY and XAUTHORITY into the linger user bus, waits for authenticated X11 readiness, and keeps its cleanup trap alive. The sample drop-in uses `%t/uu-virtual-99.Xauthority`. Use a dedicated headless account. See the [setup and official Mac acceptance checklist](contrib/virtual-desktop/ACCEPTANCE.md). + +### Arch Linux / Omarchy + +```sh +sudo pacman -S --needed base-devel rust pkgconf clang ffmpeg libx11 libxext libxtst libxfixes gtk3 \ + wayland libxkbcommon wl-clipboard libpipewire glib2 libpulse +cargo test --locked --features wayland +cargo build --release --features wayland +``` + +Omarchy uses Hyprland: run in its user session, select `UU_DESKTOP_BACKEND=wayland`, +and retain `WAYLAND_DISPLAY` / `XDG_RUNTIME_DIR`. This requires wlr-screencopy and the +virtual input protocols supported by Hyprland; other compositors may need `--features wayland,portal`. +For uinput, load `uinput` and apply the uaccess rule above; seat ACLs require an active login. +For unattended accounts, explicitly restrict `/dev/uinput` access to a dedicated group. +This permission can inject into the whole seat, including lock/greeter screens. +`UU_INPUT_BACKEND=uinput` requests kernel devices; verify startup actually reports uinput. +Optional VAAPI: `intel-media-driver` (modern Intel) or `libva-mesa-driver` (AMD), `libva-utils` +for `vainfo`. Optional KMS: `libdrm`. Virtual Xfce: `xorg-server-xvfb xorg-xauth xorg-xdpyinfo +xfce4-session xfce4-panel xfdesktop xfwm4 gnome-terminal`. +Rolling Arch FFmpeg may be newer than supported `inproc-av` (FFmpeg 6.x); use the default process +pipeline or build against a separate FFmpeg 6 prefix. Do not downgrade the system FFmpeg. +User-bus headless setup and the official Mac checklist: [virtual desktop acceptance](contrib/virtual-desktop/ACCEPTANCE.md). diff --git a/src/clipboard_probe.rs b/src/clipboard_probe.rs index f2c73ea..7d6cf5f 100644 --- a/src/clipboard_probe.rs +++ b/src/clipboard_probe.rs @@ -4,9 +4,13 @@ pub fn run() -> Result<(),String> { if std::fs::read_to_string("/proc/sys/kernel/hostname").unwrap_or_default().trim()!="uu-hyprland-test" { return Err("Clipboard acceptance is restricted to the isolated VM".into()); } - let session=Arc::new(crate::portal::PortalSession::open()?); - let bridge=crate::clipboard::start_portal(session.clone()); - if !bridge.ready.blocking_recv().unwrap_or(false) { return Err("Portal clipboard permission not granted".into()); } + let screen=crate::capture::ScreenCapture::new()?; + let input=Arc::new(crate::input::InputInjector::new()); + input.bind_portal(screen.portal.clone()); + let pointer=input.start_pointer_worker(); + let bridge=if let Some(session)=screen.portal.clone() { crate::clipboard::start_portal(session) } + else { crate::clipboard::start(screen.display.clone()) }; + if !bridge.ready.blocking_recv().unwrap_or(false) { return Err("Desktop clipboard permission not granted".into()); } let mut child=Command::new("python3").arg("/home/uuremote/clipboard-acceptance.py") .env("GDK_BACKEND","wayland").env("GSK_RENDERER","cairo") .stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::null()).spawn().map_err(|_|"Start GTK clipboard fixture")?; @@ -29,13 +33,14 @@ pub fn run() -> Result<(),String> { bridge.incoming.send_replace(Some(text.clone())); let deadline=Instant::now()+Duration::from_secs(6);let mut matched=false; while Instant::now() Result<(),String> { if outgoing.has_changed().unwrap_or(false) && outgoing.borrow_and_update().as_deref()==Some(external) {matched=true;break;} std::thread::sleep(Duration::from_millis(100)); } - if !matched { return Err("Portal clipboard outgoing Unicode mismatch".into()); } - println!("Portal clipboard outgoing unicode: passed"); + if !matched { return Err("Desktop clipboard outgoing Unicode mismatch".into()); } + println!("Desktop clipboard outgoing unicode: passed"); bridge.incoming.send_replace(Some("x".repeat(crate::clipboard::MAX_TEXT+1))); std::thread::sleep(Duration::from_millis(400)); if !check("read",external)? { return Err("Oversized text altered native clipboard".into()); } - println!("Portal clipboard incoming oversized rejection: passed"); + println!("Desktop clipboard incoming oversized rejection: passed"); if !check("set",&"y".repeat(crate::clipboard::MAX_TEXT+1))? { return Err("GTK oversized fixture setup failed".into()); } std::thread::sleep(Duration::from_secs(3)); - if outgoing.has_changed().unwrap_or(false) { return Err("Portal clipboard published oversized native text".into()); } - println!("Portal clipboard outgoing oversized rejection: passed"); + if outgoing.has_changed().unwrap_or(false) { return Err("Desktop clipboard published oversized native text".into()); } + println!("Desktop clipboard outgoing oversized rejection: passed"); if !check("set","")? { return Err("GTK empty fixture setup failed".into()); } let deadline=Instant::now()+Duration::from_secs(6);let mut matched=false; while Instant::now() Result<(), Box> { env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init(); // An unknown argument must never fall through to starting a second full host server. - const SUBCOMMANDS: [&str; 10] = ["virtual-audio-probe", "login", "unlock-check", "desktop-probe", "desktop-video-probe", "desktop-audio-probe", "wayland-capture", + const SUBCOMMANDS: [&str; 11] = ["desktop-input-probe", "virtual-audio-probe", "login", "unlock-check", "desktop-probe", "desktop-video-probe", "desktop-audio-probe", "wayland-capture", "wayland-input-probe", "clipboard-acceptance", "portal-acceptance"]; if let Some(arg) = std::env::args().nth(1).filter(|a| !SUBCOMMANDS.contains(&a.as_str())) { let usage = format!("usage: uuremote-server [{}]\n (no argument: run the host)", SUBCOMMANDS.join(" | ")); @@ -165,6 +165,30 @@ async fn main() -> Result<(), Box> { let path=std::env::args().nth(2); return video::probe((screen.width,screen.height),screen.display.clone(),screen.portal.clone(),path).await.map_err(|e|e.into()); } + if std::env::args().nth(1).as_deref() == Some("desktop-input-probe") { + if std::fs::read_to_string("/proc/sys/kernel/hostname").unwrap_or_default().trim()!="uu-hyprland-test" { + return Err("Input acceptance is restricted to the isolated VM".into()); + } + let screen=ScreenCapture::new()?; + let input=Arc::new(InputInjector::new()); + input.bind_portal(screen.portal.clone()); + let worker=input.start_pointer_worker(); + // libinput discovers newly created uinput devices asynchronously. + tokio::time::sleep(std::time::Duration::from_secs(1)).await; + input.mouse_absolute_normalized(0.25,0.25,(screen.width,screen.height)); + tokio::time::sleep(std::time::Duration::from_millis(100)).await; + input.mouse_absolute_normalized(0.5,0.5,(screen.width,screen.height)); + tokio::time::sleep(std::time::Duration::from_millis(100)).await; + input.mouse_button(1,true); input.mouse_button(1,false); + tokio::time::sleep(std::time::Duration::from_millis(100)).await; + input.mouse_relative(32,0); + tokio::time::sleep(std::time::Duration::from_millis(200)).await; + for key in b"UUWAYLAND" { input.windows_key_event(i32::from(*key),true); input.windows_key_event(i32::from(*key),false); } + tokio::time::sleep(std::time::Duration::from_millis(300)).await; + worker.abort(); input.release_held(); + println!("Desktop test events sent; verify the GTK acceptance report"); + return Ok(()); + } if std::env::args().nth(1).as_deref() == Some("wayland-input-probe") { return wayland::input_probe().map_err(|e|e.into()); }