Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d349e6ff6a | ||
|
|
01e7ed7218 | ||
|
|
3c78382f20 | ||
|
|
2833b08a37 | ||
|
|
8fd476d81c | ||
|
|
31aaab0fee | ||
|
|
5245c9ee61 | ||
|
|
9f12a88a08 | ||
|
|
2b41541128 | ||
|
|
d47178916f | ||
|
|
3dc3b62477 | ||
|
|
bb6476a864 | ||
|
|
17a09e08a5 |
No files matched your search
Generated
+1
-1
@@ -1413,7 +1413,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "uur"
|
||||
version = "0.1.2"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ashpd",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "uur"
|
||||
version = "0.1.2"
|
||||
version = "0.1.4"
|
||||
edition = "2021"
|
||||
description = "Native Linux companion for NetEase UU Remote: X11/Wayland input and capture, packaged as a regular desktop app"
|
||||
license = "MIT"
|
||||
|
||||
@@ -69,7 +69,7 @@ recipes and release artifacts share one version and filesystem layout.
|
||||
Install a downloaded release package with pacman:
|
||||
|
||||
```bash
|
||||
sudo pacman -U ./dist/uur-0.1.2-1-x86_64.pkg.tar.zst
|
||||
sudo pacman -U ./dist/uur-0.1.4-1-x86_64.pkg.tar.zst
|
||||
```
|
||||
|
||||
### AUR
|
||||
@@ -83,13 +83,13 @@ paru -S uur
|
||||
### Debian and Ubuntu package family
|
||||
|
||||
```bash
|
||||
sudo apt install ./uur_0.1.2_amd64.deb
|
||||
sudo apt install ./uur_0.1.4_amd64.deb
|
||||
```
|
||||
|
||||
### Fedora and compatible RPM systems
|
||||
|
||||
```bash
|
||||
sudo dnf install ./uur-0.1.2-1.x86_64.rpm
|
||||
sudo dnf install ./uur-0.1.4-1.x86_64.rpm
|
||||
```
|
||||
|
||||
On systems with different RPM dependency names, install the dependencies
|
||||
@@ -98,7 +98,7 @@ manually or use the portable archive.
|
||||
### Portable archive
|
||||
|
||||
```bash
|
||||
sudo tar --zstd -C / -xf ./uur-0.1.2-linux-x86_64.tar.zst
|
||||
sudo tar --zstd -C / -xf ./uur-0.1.4-linux-x86_64.tar.zst
|
||||
```
|
||||
|
||||
### Nix and NixOS
|
||||
@@ -154,6 +154,10 @@ uur display source virtual
|
||||
uur stop # Stop only uur's helpers and Wine prefix
|
||||
```
|
||||
|
||||
If UU was started from the desktop, choose **Quit** from the launcher's
|
||||
application actions. When running from a terminal, use `uur stop` or press
|
||||
Ctrl+C.
|
||||
|
||||
Diagnostic input overrides:
|
||||
|
||||
```bash
|
||||
|
||||
+7
-4
@@ -66,7 +66,7 @@ uur run
|
||||
使用 pacman 安装下载的正式发布包:
|
||||
|
||||
```bash
|
||||
sudo pacman -U ./dist/uur-0.1.2-1-x86_64.pkg.tar.zst
|
||||
sudo pacman -U ./dist/uur-0.1.4-1-x86_64.pkg.tar.zst
|
||||
```
|
||||
|
||||
### AUR
|
||||
@@ -80,13 +80,13 @@ paru -S uur
|
||||
### Debian、Ubuntu 及兼容发行版
|
||||
|
||||
```bash
|
||||
sudo apt install ./uur_0.1.2_amd64.deb
|
||||
sudo apt install ./uur_0.1.4_amd64.deb
|
||||
```
|
||||
|
||||
### Fedora 及兼容 RPM 发行版
|
||||
|
||||
```bash
|
||||
sudo dnf install ./uur-0.1.2-1.x86_64.rpm
|
||||
sudo dnf install ./uur-0.1.4-1.x86_64.rpm
|
||||
```
|
||||
|
||||
如果发行版的 RPM 依赖名称不同,请手动安装依赖或使用通用压缩包。
|
||||
@@ -94,7 +94,7 @@ sudo dnf install ./uur-0.1.2-1.x86_64.rpm
|
||||
### 通用压缩包
|
||||
|
||||
```bash
|
||||
sudo tar --zstd -C / -xf ./uur-0.1.2-linux-x86_64.tar.zst
|
||||
sudo tar --zstd -C / -xf ./uur-0.1.4-linux-x86_64.tar.zst
|
||||
```
|
||||
|
||||
### Nix 与 NixOS
|
||||
@@ -149,6 +149,9 @@ uur display source virtual
|
||||
uur stop # 只停止 uur 助手与专用 Wine 前缀
|
||||
```
|
||||
|
||||
从桌面启动 UU 后,可在启动器的应用操作菜单中选择“退出”;从终端运行时可执行
|
||||
`uur stop` 或按 Ctrl+C。
|
||||
|
||||
输入后端排错:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -12,13 +12,13 @@ needed for system-wide package installation.
|
||||
paru -S uur
|
||||
|
||||
# Downloaded release package
|
||||
sudo pacman -U ./uur-0.1.2-1-x86_64.pkg.tar.zst
|
||||
sudo pacman -U ./uur-0.1.4-1-x86_64.pkg.tar.zst
|
||||
```
|
||||
|
||||
## Debian, Ubuntu, and derivatives
|
||||
|
||||
```bash
|
||||
sudo apt install ./uur_0.1.2_amd64.deb
|
||||
sudo apt install ./uur_0.1.4_amd64.deb
|
||||
```
|
||||
|
||||
The same release artifact covers Debian, Ubuntu, Linux Mint, Pop!_OS, KDE neon,
|
||||
@@ -28,10 +28,10 @@ derivatives.
|
||||
## Fedora, RHEL, and openSUSE families
|
||||
|
||||
```bash
|
||||
sudo dnf install ./uur-0.1.2-1.x86_64.rpm
|
||||
sudo dnf install ./uur-0.1.4-1.x86_64.rpm
|
||||
|
||||
# openSUSE
|
||||
sudo zypper install ./uur-0.1.2-1.x86_64.rpm
|
||||
sudo zypper install ./uur-0.1.4-1.x86_64.rpm
|
||||
```
|
||||
|
||||
This format also covers Fedora derivatives and RPM systems whose repositories
|
||||
@@ -42,7 +42,7 @@ provide the declared Wine, GLib, PipeWire, and portal dependencies.
|
||||
The portable archive targets conventional glibc/FHS systems:
|
||||
|
||||
```bash
|
||||
sudo tar --zstd -C / -xf ./uur-0.1.2-linux-x86_64.tar.zst
|
||||
sudo tar --zstd -C / -xf ./uur-0.1.4-linux-x86_64.tar.zst
|
||||
```
|
||||
|
||||
## Nix and NixOS
|
||||
|
||||
@@ -46,7 +46,7 @@ paru -S uur
|
||||
From a downloaded Arch package:
|
||||
|
||||
```bash
|
||||
sudo pacman -U ./uur-0.1.2-1-x86_64.pkg.tar.zst
|
||||
sudo pacman -U ./uur-0.1.4-1-x86_64.pkg.tar.zst
|
||||
```
|
||||
|
||||
Install the portal backend supplied or recommended by the selected desktop.
|
||||
@@ -60,7 +60,7 @@ Zorin OS, elementary OS, KDE neon, TUXEDO OS, Kali Linux, MX Linux, and other
|
||||
compatible derivatives:
|
||||
|
||||
```bash
|
||||
sudo apt install ./uur_0.1.2_amd64.deb
|
||||
sudo apt install ./uur_0.1.4_amd64.deb
|
||||
```
|
||||
|
||||
The package manager resolves Wine, PipeWire, and the portal frontend. Install
|
||||
@@ -74,10 +74,10 @@ dependency names. Install it with the native frontend:
|
||||
|
||||
```bash
|
||||
# Fedora and compatible systems
|
||||
sudo dnf install ./uur-0.1.2-1.x86_64.rpm
|
||||
sudo dnf install ./uur-0.1.4-1.x86_64.rpm
|
||||
|
||||
# openSUSE family
|
||||
sudo zypper install ./uur-0.1.2-1.x86_64.rpm
|
||||
sudo zypper install ./uur-0.1.4-1.x86_64.rpm
|
||||
```
|
||||
|
||||
RHEL, CentOS Stream, Rocky Linux, AlmaLinux, Oracle Linux, Nobara, Ultramarine,
|
||||
@@ -91,7 +91,7 @@ PCLinuxOS, and similar mutable/FHS systems can use the portable archive when
|
||||
they provide compatible glibc, Wine, PipeWire, and portal libraries:
|
||||
|
||||
```bash
|
||||
sudo tar --zstd -C / -xf ./uur-0.1.2-linux-x86_64.tar.zst
|
||||
sudo tar --zstd -C / -xf ./uur-0.1.4-linux-x86_64.tar.zst
|
||||
```
|
||||
|
||||
Alternatively, build and install for one user:
|
||||
|
||||
@@ -55,6 +55,7 @@ session:
|
||||
webview_failed: "WebView2 installation failed"
|
||||
quick_launch_ready: "%{count} Linux applications exported to UU Quick Launch"
|
||||
audio_backend: "Wine audio backend: %{backend}"
|
||||
wine_dpi: "Wine system DPI set from Xft.dpi: %{dpi}"
|
||||
|
||||
setup:
|
||||
eula_prompt: "The official UU Remote client will be downloaded from NetEase and is governed by their EULA: %{url}\nRe-run with --accept-eula to continue."
|
||||
|
||||
@@ -43,6 +43,7 @@ session:
|
||||
webview_failed: "WebView2 安装失败"
|
||||
quick_launch_ready: "已向 UU 快速启动导出 %{count} 个 Linux 应用"
|
||||
audio_backend: "Wine 音频后端:%{backend}"
|
||||
wine_dpi: "已根据 Xft.dpi 设置 Wine 系统 DPI:%{dpi}"
|
||||
|
||||
upstream:
|
||||
unreachable: "无法访问网易官方发布接口"
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ let
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "uur";
|
||||
version = "0.1.2";
|
||||
version = "0.1.4";
|
||||
|
||||
src = lib.cleanSource ../.;
|
||||
cargoLock.lockFile = ../Cargo.lock;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Contributor: uur contributors
|
||||
# Maintainer: uur contributors
|
||||
pkgname=uur
|
||||
pkgver=0.1.2
|
||||
pkgver=0.1.4
|
||||
pkgrel=0
|
||||
pkgdesc="Native Linux companion for NetEase UU Remote"
|
||||
url="https://github.com/panxuc/uur"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
pkgbase = uur
|
||||
pkgdesc = Native Linux companion for NetEase UU Remote (X11/Wayland input and capture bridge)
|
||||
pkgver = 0.1.2
|
||||
pkgver = 0.1.4
|
||||
pkgrel = 1
|
||||
url = https://github.com/panxuc/uur
|
||||
install = uur.install
|
||||
@@ -31,7 +31,7 @@ pkgbase = uur
|
||||
optdepends = libva-utils: VA-API capability diagnostics
|
||||
optdepends = vulkan-tools: Vulkan and Vulkan Video capability diagnostics
|
||||
optdepends = nvidia-utils: NVENC and NVDEC capability diagnostics on NVIDIA GPUs
|
||||
source = uur-0.1.2.tar.gz::https://github.com/panxuc/uur/archive/refs/tags/v0.1.2.tar.gz
|
||||
source = uur-0.1.4.tar.gz::https://github.com/panxuc/uur/archive/refs/tags/v0.1.4.tar.gz
|
||||
sha256sums = SKIP
|
||||
|
||||
pkgname = uur
|
||||
@@ -8,7 +8,7 @@
|
||||
# `uur setup` (it is never redistributed by this package).
|
||||
|
||||
pkgname=uur
|
||||
pkgver=0.1.2
|
||||
pkgver=0.1.4
|
||||
pkgrel=1
|
||||
pkgdesc="Native Linux companion for NetEase UU Remote (X11/Wayland input and capture bridge)"
|
||||
arch=('x86_64')
|
||||
|
||||
@@ -9,6 +9,13 @@ Comment[zh_CN]=在本 Linux 桌面启动完整的 UU 远程会话
|
||||
Exec=uur run
|
||||
TryExec=uur
|
||||
Icon=uur
|
||||
StartupWMClass=gameviewer.exe
|
||||
Terminal=false
|
||||
Categories=Network;RemoteAccess;
|
||||
Keywords=remote;desktop;uu;网易;远程;
|
||||
Actions=Quit;
|
||||
|
||||
[Desktop Action Quit]
|
||||
Name=Quit
|
||||
Name[zh_CN]=退出
|
||||
Exec=uur stop
|
||||
@@ -219,6 +219,7 @@ fn pump(stream: &mut TcpStream, backend: &mut dyn input::InputBackend) -> Result
|
||||
let mut header = [0u8; protocol::HEADER_BYTES];
|
||||
let mut record = [0u8; RECORD_BYTES];
|
||||
let mut injected: u64 = 0;
|
||||
let mut warned_unsupported_key = false;
|
||||
loop {
|
||||
// EOF is the hook exiting: a clean disconnect, not an error.
|
||||
match stream.read_exact(&mut header) {
|
||||
@@ -236,6 +237,19 @@ fn pump(stream: &mut TcpStream, backend: &mut dyn input::InputBackend) -> Result
|
||||
protocol::RECORD_MOUSE | protocol::RECORD_KEYBOARD => {
|
||||
stream.read_exact(&mut record)?;
|
||||
let record = protocol::read_record(&record);
|
||||
if record.kind == protocol::RECORD_KEYBOARD && record.code == 0 {
|
||||
// Unicode and scan-code SendInput events do not carry a
|
||||
// virtual-key code. Text/scan-code transport is not
|
||||
// supported yet, but one such event must not tear down
|
||||
// the connection and block later ordinary key events.
|
||||
if !warned_unsupported_key {
|
||||
eprintln!(
|
||||
"ignoring keyboard input without a virtual-key code; Unicode and scan-code input are not supported yet"
|
||||
);
|
||||
warned_unsupported_key = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
dispatch(backend, &record)?;
|
||||
injected += 1;
|
||||
}
|
||||
@@ -302,6 +316,9 @@ mod tests {
|
||||
"test"
|
||||
}
|
||||
fn key(&mut self, code: u16, down: bool) -> Result<()> {
|
||||
if code == 0 {
|
||||
anyhow::bail!("invalid virtual-key code");
|
||||
}
|
||||
self.0.send(format!("key {code} {down}"))?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -342,6 +359,39 @@ mod tests {
|
||||
)
|
||||
}
|
||||
|
||||
fn input_packet(kind: u32, code: u16, state: u16) -> Vec<u8> {
|
||||
let mut packet = Vec::new();
|
||||
for value in [protocol::MAGIC, protocol::VERSION, kind, 16, kind] {
|
||||
packet.extend_from_slice(&value.to_le_bytes());
|
||||
}
|
||||
packet.extend_from_slice(&code.to_le_bytes());
|
||||
packet.extend_from_slice(&state.to_le_bytes());
|
||||
packet.extend_from_slice(&0i32.to_le_bytes());
|
||||
packet.extend_from_slice(&0i32.to_le_bytes());
|
||||
packet
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zero_virtual_key_does_not_disconnect_later_keyboard_input() {
|
||||
let (shared, events) = shared();
|
||||
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let mut client = TcpStream::connect(listener.local_addr().unwrap()).unwrap();
|
||||
let (mut server, _) = listener.accept().unwrap();
|
||||
let mut backend = connection(&shared);
|
||||
let thread = thread::spawn(move || pump(&mut server, &mut backend).unwrap());
|
||||
|
||||
client
|
||||
.write_all(&input_packet(protocol::RECORD_KEYBOARD, 0, 1))
|
||||
.unwrap();
|
||||
client
|
||||
.write_all(&input_packet(protocol::RECORD_KEYBOARD, 65, 1))
|
||||
.unwrap();
|
||||
drop(client);
|
||||
|
||||
assert_eq!(thread.join().unwrap(), 1);
|
||||
assert_eq!(events.try_iter().collect::<Vec<_>>(), ["key 65 true"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn idle_connection_does_not_block_another_connections_motion() {
|
||||
let (shared, events) = shared();
|
||||
|
||||
+231
-9
@@ -4,10 +4,11 @@
|
||||
//! session ends.
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::{Read, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Child, Command, Stdio};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
|
||||
@@ -93,6 +94,68 @@ fn hook_source_dir() -> Result<PathBuf> {
|
||||
.context("hook DLLs not found (run the build first)")
|
||||
}
|
||||
|
||||
static DEPLOY_TEMP_SEQUENCE: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
/// Replace a managed prefix file without inheriting the source's permissions.
|
||||
/// Nix store files are read-only; copying them directly leaves the prefix
|
||||
/// read-only too, so the next run cannot overwrite them. A temporary file in
|
||||
/// the destination directory keeps the replacement atomic and also repairs
|
||||
/// read-only files left by earlier uur versions.
|
||||
fn deploy_file(source: &Path, target: &Path) -> Result<()> {
|
||||
let parent = target
|
||||
.parent()
|
||||
.filter(|parent| !parent.as_os_str().is_empty())
|
||||
.unwrap_or_else(|| Path::new("."));
|
||||
let filename = target
|
||||
.file_name()
|
||||
.context("deployment target has no file name")?
|
||||
.to_string_lossy();
|
||||
|
||||
let mut temporary = None;
|
||||
for _ in 0..32 {
|
||||
let sequence = DEPLOY_TEMP_SEQUENCE.fetch_add(1, Ordering::Relaxed);
|
||||
let path = parent.join(format!(
|
||||
".{filename}.uur-{}-{sequence}.tmp",
|
||||
std::process::id()
|
||||
));
|
||||
match OpenOptions::new().write(true).create_new(true).open(&path) {
|
||||
Ok(file) => {
|
||||
temporary = Some((path, file));
|
||||
break;
|
||||
}
|
||||
Err(error) if error.kind() == std::io::ErrorKind::AlreadyExists => continue,
|
||||
Err(error) => {
|
||||
return Err(error).with_context(|| {
|
||||
format!("creating temporary deployment for {}", target.display())
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
let Some((temporary_path, mut output)) = temporary else {
|
||||
anyhow::bail!("could not create a temporary file for {}", target.display());
|
||||
};
|
||||
|
||||
let copy_result = (|| -> Result<()> {
|
||||
let mut input = File::open(source)
|
||||
.with_context(|| format!("opening deployment source {}", source.display()))?;
|
||||
std::io::copy(&mut input, &mut output)
|
||||
.with_context(|| format!("copying deployment source {}", source.display()))?;
|
||||
output.flush()?;
|
||||
Ok(())
|
||||
})();
|
||||
drop(output);
|
||||
if let Err(error) = copy_result {
|
||||
let _ = std::fs::remove_file(&temporary_path);
|
||||
return Err(error);
|
||||
}
|
||||
|
||||
if let Err(error) = std::fs::rename(&temporary_path, target) {
|
||||
let _ = std::fs::remove_file(&temporary_path);
|
||||
return Err(error).with_context(|| format!("deploying to {}", target.display()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Install the native preload DLLs in the managed prefix, outside the
|
||||
/// proprietary application directory. Wine's native override resolves them
|
||||
/// from system32, so client updates never overwrite uur and uur never edits an
|
||||
@@ -104,7 +167,7 @@ fn deploy_hooks(prefix: &Path) -> Result<()> {
|
||||
for dll in ["wevtapi.dll", "uur-hook.dll", "wtsapi32.dll"] {
|
||||
let from = source.join(dll);
|
||||
let to = target.join(dll);
|
||||
std::fs::copy(&from, &to)
|
||||
deploy_file(&from, &to)
|
||||
.with_context(|| format!("deploying {} to {}", dll, target.display()))?;
|
||||
}
|
||||
Ok(())
|
||||
@@ -152,7 +215,7 @@ fn deploy_terminal_proxy(install_dir: &Path) -> Result<PathBuf> {
|
||||
std::fs::copy(&target, &backup)
|
||||
.with_context(|| format!("backing up {}", target.display()))?;
|
||||
}
|
||||
std::fs::copy(&source, &target)
|
||||
deploy_file(&source, &target)
|
||||
.with_context(|| format!("deploying native terminal proxy to {}", target.display()))?;
|
||||
std::fs::write(marker, b"managed by uur\n")?;
|
||||
|
||||
@@ -163,7 +226,7 @@ fn deploy_terminal_proxy(install_dir: &Path) -> Result<PathBuf> {
|
||||
std::fs::copy(&mux_target, &mux_backup)
|
||||
.with_context(|| format!("backing up {}", mux_target.display()))?;
|
||||
}
|
||||
std::fs::copy(&mux_source, &mux_target)
|
||||
deploy_file(&mux_source, &mux_target)
|
||||
.with_context(|| format!("deploying native mux proxy to {}", mux_target.display()))?;
|
||||
std::fs::write(mux_marker, b"managed by uur\n")?;
|
||||
Ok(bin.join("uu-terminal-bridge.runtime"))
|
||||
@@ -171,6 +234,22 @@ fn deploy_terminal_proxy(install_dir: &Path) -> Result<PathBuf> {
|
||||
|
||||
/// The client UI needs the Evergreen WebView2 runtime; the official
|
||||
/// bootstrapper ships inside the client's bin directory.
|
||||
const WEBVIEW2_DLL_OVERRIDES: &str = "wtsapi32=b,wevtapi=b";
|
||||
|
||||
fn webview2_install_command(prefix: &Path, bootstrapper: &Path) -> Command {
|
||||
let mut command = Command::new("wine");
|
||||
command
|
||||
.env("WINEPREFIX", prefix)
|
||||
.env("WINEDEBUG", wine_debug())
|
||||
// The bootstrapper is a 32-bit process. uur's native preload DLLs are
|
||||
// 64-bit, so inherited global native-only overrides make its updater
|
||||
// unable to load WTSAPI32.dll under WoW64.
|
||||
.env("WINEDLLOVERRIDES", WEBVIEW2_DLL_OVERRIDES)
|
||||
.arg(bootstrapper)
|
||||
.args(["/silent", "/install"]);
|
||||
command
|
||||
}
|
||||
|
||||
fn ensure_webview2(prefix: &Path, install_dir: &Path) -> Result<()> {
|
||||
let marker = prefix.join("drive_c/Program Files (x86)/Microsoft/EdgeWebView/Application");
|
||||
if marker.exists() {
|
||||
@@ -183,11 +262,7 @@ fn ensure_webview2(prefix: &Path, install_dir: &Path) -> Result<()> {
|
||||
anyhow::bail!("{}", t!("session.webview_missing"));
|
||||
}
|
||||
println!("{}", t!("session.installing_webview"));
|
||||
let status = Command::new("wine")
|
||||
.env("WINEPREFIX", prefix)
|
||||
.env("WINEDEBUG", wine_debug())
|
||||
.arg(bootstrapper.to_string_lossy().as_ref())
|
||||
.args(["/silent", "/install"])
|
||||
let status = webview2_install_command(prefix, &bootstrapper)
|
||||
.status()
|
||||
.context("running the WebView2 bootstrapper")?;
|
||||
if !status.success() {
|
||||
@@ -333,6 +408,12 @@ pub fn start() -> Result<()> {
|
||||
let prefix = data_dir()?.join("wine");
|
||||
let install_dir = crate::wine::find_client_dir(&prefix)
|
||||
.context("client not provisioned; run `uur setup` first")?;
|
||||
if let Some(dpi) = xft_dpi() {
|
||||
match crate::wine::set_log_pixels(&prefix, dpi) {
|
||||
Ok(()) => println!("{}", t!("session.wine_dpi", dpi = dpi)),
|
||||
Err(error) => eprintln!("could not sync Wine DPI from Xft.dpi: {error}"),
|
||||
}
|
||||
}
|
||||
deploy_hooks(&prefix)?;
|
||||
crate::wine::set_dll_override(&prefix, "wtsapi32", "native")?;
|
||||
// Re-apply migrations on every launch so an updated uur package repairs
|
||||
@@ -702,6 +783,37 @@ fn wait_for_runtime_file(path: &Path, stopping: &AtomicBool) -> Result<()> {
|
||||
anyhow::bail!("native terminal bridge did not become ready")
|
||||
}
|
||||
|
||||
fn xft_dpi() -> Option<u32> {
|
||||
use x11rb::connection::Connection;
|
||||
use x11rb::protocol::xproto::{AtomEnum, ConnectionExt};
|
||||
|
||||
let (connection, screen) = x11rb::connect(None).ok()?;
|
||||
let root = connection.setup().roots.get(screen)?.root;
|
||||
let resource_manager = connection
|
||||
.intern_atom(false, b"RESOURCE_MANAGER")
|
||||
.ok()?
|
||||
.reply()
|
||||
.ok()?
|
||||
.atom;
|
||||
let resource_manager = connection
|
||||
.get_property(false, root, resource_manager, AtomEnum::STRING, 0, 16_384)
|
||||
.ok()?
|
||||
.reply()
|
||||
.ok()?;
|
||||
parse_xft_dpi(&String::from_utf8_lossy(&resource_manager.value))
|
||||
}
|
||||
|
||||
fn parse_xft_dpi(resources: &str) -> Option<u32> {
|
||||
resources.lines().find_map(|line| {
|
||||
let (name, value) = line.split_once(':')?;
|
||||
if name.trim() != "Xft.dpi" {
|
||||
return None;
|
||||
}
|
||||
let dpi = value.trim().parse::<f64>().ok()?;
|
||||
(dpi.is_finite() && (96.0..=480.0).contains(&dpi)).then(|| dpi.round() as u32)
|
||||
})
|
||||
}
|
||||
|
||||
fn stop_wineserver(prefix: &Path) {
|
||||
let _ = Command::new("wineserver")
|
||||
.env("WINEPREFIX", prefix)
|
||||
@@ -716,6 +828,116 @@ fn wine_debug() -> String {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
struct TestDirectory(PathBuf);
|
||||
|
||||
impl TestDirectory {
|
||||
fn create() -> Self {
|
||||
static NEXT: AtomicU64 = AtomicU64::new(0);
|
||||
for _ in 0..32 {
|
||||
let path = std::env::temp_dir().join(format!(
|
||||
"uur-session-deploy-{}-{}",
|
||||
std::process::id(),
|
||||
NEXT.fetch_add(1, Ordering::Relaxed)
|
||||
));
|
||||
match std::fs::create_dir(&path) {
|
||||
Ok(()) => return Self(path),
|
||||
Err(error) if error.kind() == std::io::ErrorKind::AlreadyExists => continue,
|
||||
Err(error) => panic!("creating test directory: {error}"),
|
||||
}
|
||||
}
|
||||
panic!("could not create a unique test directory");
|
||||
}
|
||||
|
||||
fn path(&self) -> &Path {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestDirectory {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deploy_file_repairs_readonly_targets_and_is_repeatable() {
|
||||
let directory = TestDirectory::create();
|
||||
let source = directory.path().join("store/uur-hook.dll");
|
||||
let target = directory.path().join("prefix/system32/uur-hook.dll");
|
||||
std::fs::create_dir_all(source.parent().unwrap()).unwrap();
|
||||
std::fs::create_dir_all(target.parent().unwrap()).unwrap();
|
||||
std::fs::write(&source, b"new hook contents").unwrap();
|
||||
std::fs::write(&target, b"old hook contents").unwrap();
|
||||
std::fs::set_permissions(&source, std::fs::Permissions::from_mode(0o444)).unwrap();
|
||||
std::fs::set_permissions(&target, std::fs::Permissions::from_mode(0o444)).unwrap();
|
||||
|
||||
deploy_file(&source, &target).unwrap();
|
||||
assert_eq!(std::fs::read(&target).unwrap(), b"new hook contents");
|
||||
assert_ne!(
|
||||
std::fs::metadata(&target).unwrap().permissions().mode() & 0o200,
|
||||
0
|
||||
);
|
||||
|
||||
deploy_file(&source, &target).unwrap();
|
||||
assert_eq!(std::fs::read(&target).unwrap(), b"new hook contents");
|
||||
assert_ne!(
|
||||
std::fs::metadata(&target).unwrap().permissions().mode() & 0o200,
|
||||
0
|
||||
);
|
||||
assert_eq!(
|
||||
std::fs::read_dir(target.parent().unwrap()).unwrap().count(),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deploy_file_does_not_inherit_readonly_source_permissions() {
|
||||
let directory = TestDirectory::create();
|
||||
let source = directory.path().join("store/uur-hook.dll");
|
||||
let target = directory.path().join("prefix/system32/uur-hook.dll");
|
||||
std::fs::create_dir_all(source.parent().unwrap()).unwrap();
|
||||
std::fs::create_dir_all(target.parent().unwrap()).unwrap();
|
||||
std::fs::write(&source, b"hook contents").unwrap();
|
||||
std::fs::set_permissions(&source, std::fs::Permissions::from_mode(0o444)).unwrap();
|
||||
|
||||
deploy_file(&source, &target).unwrap();
|
||||
|
||||
assert_eq!(std::fs::read(&target).unwrap(), b"hook contents");
|
||||
assert_ne!(
|
||||
std::fs::metadata(&target).unwrap().permissions().mode() & 0o200,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_xft_dpi_resources() {
|
||||
assert_eq!(parse_xft_dpi("Xft.antialias: 1\nXft.dpi: 192\n"), Some(192));
|
||||
assert_eq!(parse_xft_dpi("Xft.dpi: 168.4\n"), Some(168));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignores_invalid_xft_dpi_resources() {
|
||||
assert_eq!(parse_xft_dpi("Xft.dpi: 72\n"), None);
|
||||
assert_eq!(parse_xft_dpi("Xft.dpi: 500\n"), None);
|
||||
assert_eq!(parse_xft_dpi("Xft.dpi: automatic\n"), None);
|
||||
assert_eq!(parse_xft_dpi("Xft.antialias: 192\n"), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn webview2_installer_uses_builtin_wow64_dlls() {
|
||||
let command = webview2_install_command(
|
||||
Path::new("/tmp/uur-wine-prefix"),
|
||||
Path::new("/tmp/MicrosoftEdgeWebview2Setup.exe"),
|
||||
);
|
||||
let overrides = command
|
||||
.get_envs()
|
||||
.find_map(|(name, value)| (name == OsStr::new("WINEDLLOVERRIDES")).then_some(value))
|
||||
.flatten();
|
||||
assert_eq!(overrides, Some(OsStr::new(WEBVIEW2_DLL_OVERRIDES)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tasklist_parser_matches_the_exact_image() {
|
||||
|
||||
+37
-4
@@ -276,12 +276,13 @@ fn detect_runtime_provider() -> Option<PathBuf> {
|
||||
.and_then(OsStr::to_str)
|
||||
.unwrap_or_default();
|
||||
let candidate = match executable {
|
||||
"swaybg" => argument_after(&arguments, "-i"),
|
||||
"xwallpaper" => arguments.last().cloned(),
|
||||
"mpvpaper" => arguments.last().cloned(),
|
||||
"swaybg" => argument_after(&arguments, "-i").map(PathBuf::from),
|
||||
"xwallpaper" => arguments.last().map(PathBuf::from),
|
||||
"mpvpaper" => arguments.last().map(PathBuf::from),
|
||||
"wpaperd" => wpaperd_link(&entry.path()),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(path) = candidate.and_then(|value| resolve_candidate(PathBuf::from(value))) {
|
||||
if let Some(path) = candidate.and_then(resolve_candidate) {
|
||||
return Some(path);
|
||||
}
|
||||
}
|
||||
@@ -303,6 +304,32 @@ fn argument_after(arguments: &[String], option: &str) -> Option<String> {
|
||||
.map(|pair| pair[1].clone())
|
||||
}
|
||||
|
||||
/// wpaperd >= 1.1.0 mirrors the current wallpaper of every output as a
|
||||
/// symlink under `$XDG_STATE_HOME/wpaperd/wallpapers`, rewritten on each
|
||||
/// change. Image paths are written verbatim, so absolute targets are used
|
||||
/// as-is while relative ones resolve against wpaperd's working directory.
|
||||
/// The newest resolvable link wins; leftovers from earlier runs are older.
|
||||
fn wpaperd_link(proc: &Path) -> Option<PathBuf> {
|
||||
let cwd = std::fs::read_link(proc.join("cwd")).ok()?;
|
||||
std::fs::read_dir(state_home().join("wpaperd/wallpapers"))
|
||||
.ok()?
|
||||
.flatten()
|
||||
.filter_map(|entry| {
|
||||
let link = entry.path();
|
||||
let target = std::fs::read_link(&link).ok()?;
|
||||
let target = if target.is_absolute() {
|
||||
target
|
||||
} else {
|
||||
cwd.join(target)
|
||||
};
|
||||
let path = resolve_candidate(target)?;
|
||||
let modified = std::fs::symlink_metadata(&link).ok()?.modified().ok()?;
|
||||
Some((modified, path))
|
||||
})
|
||||
.max_by_key(|(modified, _)| *modified)
|
||||
.map(|(_, path)| path)
|
||||
}
|
||||
|
||||
fn wallpaper_from_value(value: &str, provider: &'static str) -> Option<Wallpaper> {
|
||||
let value = value.trim().trim_matches(['\'', '"']);
|
||||
if value.is_empty() {
|
||||
@@ -545,6 +572,12 @@ fn config_home() -> PathBuf {
|
||||
.unwrap_or_else(|| home_dir().join(".config"))
|
||||
}
|
||||
|
||||
fn state_home() -> PathBuf {
|
||||
std::env::var_os("XDG_STATE_HOME")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| home_dir().join(".local/state"))
|
||||
}
|
||||
|
||||
fn home_dir() -> PathBuf {
|
||||
std::env::var_os("HOME")
|
||||
.map(PathBuf::from)
|
||||
|
||||
+59
@@ -239,6 +239,39 @@ pub fn set_dll_override(prefix: &Path, name: &str, mode: &str) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_log_pixels(prefix: &Path, dpi: u32) -> Result<()> {
|
||||
let status = log_pixels_command(prefix, dpi)
|
||||
.status()
|
||||
.context("setting the Wine system DPI")?;
|
||||
if !status.success() {
|
||||
anyhow::bail!("Wine rejected the system DPI value {dpi}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn log_pixels_command(prefix: &Path, dpi: u32) -> Command {
|
||||
let mut command = Command::new("wine");
|
||||
command
|
||||
.env("WINEPREFIX", prefix)
|
||||
.env("WINEDEBUG", wine_debug())
|
||||
.args([
|
||||
"reg",
|
||||
"add",
|
||||
r"HKCU\Control Panel\Desktop",
|
||||
"/v",
|
||||
"LogPixels",
|
||||
"/t",
|
||||
"REG_DWORD",
|
||||
"/d",
|
||||
&dpi.to_string(),
|
||||
"/f",
|
||||
])
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null());
|
||||
command
|
||||
}
|
||||
|
||||
fn wine_debug() -> String {
|
||||
std::env::var("WINEDEBUG").unwrap_or_else(|_| "-all".to_string())
|
||||
}
|
||||
@@ -422,7 +455,9 @@ fn purge_wine_shortcuts() {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::log_pixels_command;
|
||||
use super::registry_compat_entries;
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
fn bundled_cpp_runtime_is_preferred_for_both_uu_processes() {
|
||||
@@ -436,4 +471,28 @@ mod tests {
|
||||
assert!(values.contains(&("msvcp140", "REG_SZ", "native,builtin")));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn system_dpi_command_writes_winecfg_logpixels_value() {
|
||||
let command = log_pixels_command(Path::new("/tmp/wine-prefix"), 192);
|
||||
let args = command
|
||||
.get_args()
|
||||
.map(|arg| arg.to_string_lossy().into_owned())
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(
|
||||
args,
|
||||
[
|
||||
"reg",
|
||||
"add",
|
||||
r"HKCU\Control Panel\Desktop",
|
||||
"/v",
|
||||
"LogPixels",
|
||||
"/t",
|
||||
"REG_DWORD",
|
||||
"/d",
|
||||
"192",
|
||||
"/f",
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user