Skip to content

Commit

Permalink
feat: set WAYLAND_DISPLAY based on environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
donovanglover committed Oct 27, 2024
1 parent c0cf177 commit d8582e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/server/routes/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::state::Options;
pub async fn open(Json(options): Json<Options>) -> Result<String, &'static str> {
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")
Expand Down
7 changes: 5 additions & 2 deletions src/state/options.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use serde::Deserialize;
use serde::Serialize;
use std::env::var;

use crate::consts::DEFAULT_WINE32_PREFIX;

#[derive(Serialize, Deserialize)]
pub struct Options {
pub wine_prefix: String,
pub path: String,
pub wayland_display: String,
pub xdg_runtime_dir: String,
pub display: String,
}
Expand All @@ -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(),
}
}
}

0 comments on commit d8582e8

Please sign in to comment.