Skip to content

Commit

Permalink
check if is $XAUTHORITY set
Browse files Browse the repository at this point in the history
  • Loading branch information
h-leth committed Jan 7, 2025
1 parent 1d4be7d commit 783ea39
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/post_login/x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ 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}`",
Expand Down

0 comments on commit 783ea39

Please sign in to comment.