From d8582e80cb525e6d0c2e2932b28ac66e239d4c7e Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Sun, 27 Oct 2024 12:11:51 -0400 Subject: [PATCH] feat: set WAYLAND_DISPLAY based on environment variable --- src/server/routes/open.rs | 2 +- src/state/options.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/server/routes/open.rs b/src/server/routes/open.rs index ce01cf3..b411e45 100644 --- a/src/server/routes/open.rs +++ b/src/server/routes/open.rs @@ -7,7 +7,7 @@ use crate::state::Options; pub async fn open(Json(options): Json) -> Result { let Ok(Output { stdout, stderr, .. }) = Command::new("wine") .env("WINEPREFIX", options.wine_prefix) - .env("WAYLAND_DISPLAY", "wayland-1") + .env("WAYLAND_DISPLAY", options.wayland_display) .env("XDG_RUNTIME_DIR", options.xdg_runtime_dir) .env("DISPLAY", options.display) .env("XAUTHORITY", "/tmp/.X11-unix/Xauthority") diff --git a/src/state/options.rs b/src/state/options.rs index 2901137..d9f3beb 100644 --- a/src/state/options.rs +++ b/src/state/options.rs @@ -1,5 +1,6 @@ use serde::Deserialize; use serde::Serialize; +use std::env::var; use crate::consts::DEFAULT_WINE32_PREFIX; @@ -7,6 +8,7 @@ use crate::consts::DEFAULT_WINE32_PREFIX; pub struct Options { pub wine_prefix: String, pub path: String, + pub wayland_display: String, pub xdg_runtime_dir: String, pub display: String, } @@ -26,8 +28,9 @@ impl Default for Options { Self { wine_prefix: DEFAULT_WINE32_PREFIX.to_string(), path: "/tmp/sakaya".to_string(), - xdg_runtime_dir: std::env::var_os("XDG_RUNTIME_DIR").unwrap().into_string().unwrap(), - display: std::env::var_os("DISPLAY").unwrap().into_string().unwrap(), + wayland_display: var("WAYLAND_DISPLAY").unwrap_or_default(), + xdg_runtime_dir: var("XDG_RUNTIME_DIR").unwrap(), + display: var("DISPLAY").unwrap(), } } }