From 1c09da31b32dafc8ca84fb09d011f50052611d13 Mon Sep 17 00:00:00 2001 From: Henning Leth Date: Tue, 7 Jan 2025 21:38:00 +0100 Subject: [PATCH 1/2] check if is $XAUTHORITY set --- src/post_login/x.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/post_login/x.rs b/src/post_login/x.rs index 0c3eb71..c66c43e 100644 --- a/src/post_login/x.rs +++ b/src/post_login/x.rs @@ -85,8 +85,12 @@ pub fn setup_x( let vtnr_value = env::var("XDG_VTNR").map_err(|_| XSetupError::VTNREnvVar)?; // Setup xauth - let xauth_dir = PathBuf::from(env::var("HOME").map_err(|_| XSetupError::HomeEnvVar)?); - let xauth_path = xauth_dir.join(".Xauthority"); + info!("Check if `XAUTHORITY` enviroment variable is set"); + let xauth_path = match env::var("XAUTHORITY") { + Ok(var) => PathBuf::from(env::var(var).map_err(|_| XSetupError::FillingXAuth)?), + Err(_) => PathBuf::from(env::var("HOME").map_err(|_| XSetupError::HomeEnvVar)?) + .join(".Xauthority"), + }; info!( "Filling `.Xauthority` file at `{xauth_path}`", From 7b3af2995f70f8af66bfe314bff4beba2bd81a3b Mon Sep 17 00:00:00 2001 From: Henning Leth Date: Thu, 9 Jan 2025 19:46:15 +0100 Subject: [PATCH 2/2] change process_env.set to .set_or_own for XAUTHORITY --- src/post_login/x.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/post_login/x.rs b/src/post_login/x.rs index c66c43e..5c60ca9 100644 --- a/src/post_login/x.rs +++ b/src/post_login/x.rs @@ -123,7 +123,7 @@ pub fn setup_x( })?; let xauth_path = xauth_path.to_str().ok_or(XSetupError::InvalidUTF8Path)?; - process_env.set("XAUTHORITY", xauth_path); + process_env.set_or_own("XAUTHORITY", xauth_path); let doubledigit_vtnr = if vtnr_value.len() == 1 { format!("0{vtnr_value}")